R-stacked-grouped barplot with different fill in R

假装没事ソ 提交于 2019-12-06 02:17:24
Mike H.

You could simply add the two different layers to your plot one for each KK value. Unfortunately, ggplot does not handle patterns well (or at all really), see this post: How to add texture to fill colors in ggplot2?

The code to add different layers for each KK value is:

ggplot() + 
  geom_bar(data=df2[which(df2$KK==10),], aes(k, value, fill = variable),stat = 'identity',position="dodge") +
  geom_bar(data=df2[which(df2$KK==30),], aes(k, value, fill = variable),stat = 'identity',position="dodge",alpha=0.5) +
  theme(legend.position = 'top')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!