R ggplot transparency - alpha values conditional on other variable

后端 未结 2 549
攒了一身酷
攒了一身酷 2021-02-18 22:39

I have the following data: [example from R graphics Cookbook]

Cultivar Date Weight sd          n  se          big
c39     d16   3.18  0.9566144   10  0.30250803          


        
2条回答
  •  孤独总比滥情好
    2021-02-18 23:39

    Another possibility using scale_alpha_discrete, where the range argument may be used to set your desired alpha values for each level of 'big'.

    ggplot(data = cabbage_exp, aes(x = Date, y = Weight, fill = Cultivar, alpha = big)) +
      geom_bar(position = "dodge", stat = "identity") +
      scale_alpha_discrete(range = c(0.35, 0.9))
    

    enter image description here

提交回复
热议问题