Make the border on one bar darker than the others

前端 未结 2 575
滥情空心
滥情空心 2021-02-05 22:01

I have created a bar graph in ggplot2 where 3 bars represent the probability of making 1 of 3 choices.

I want to add a bolded border around the bar that

2条回答
  •  一个人的身影
    2021-02-05 22:31

    Similar to Troy's answer, but rather than creating a layer of invisible bars, you can use the size aesthetic and scale_size_manual:

    require(ggplot2)
    data(diamonds)
    
    diamonds$choose = factor(diamonds$clarity == "SI1")
    
    ggplot(diamonds) + 
      geom_bar(aes(x = clarity, fill=clarity, size=choose), color="black") +
      scale_size_manual(values=c(0.5, 1), guide = "none") +
      facet_wrap(~ cut)
    

    Which produces the following plot:

    enter image description here

提交回复
热议问题