我使用以下方法在彼此之上绘制了两个条形图:
library(ggplot2)
library(reshape2)
x = c("type1", "type2", "type3")
y1 = c("1","2","3")
y2 = c("2","3","4")
to_plot <- data.frame(x=x,y1=y1,y2=y2)
melted<-melt(to_plot, id="x")
ggplot() + geom_bar(data=melted,aes(x=x,y=value,fill=variable),stat="identity",position = "identity", alpha=.3)
无论如何我可以更改条形图的颜色吗?例如,我希望 y1 图与背景相同的灰色
ggplot() + geom_bar(data=melted,aes(x=x,y=value,fill=variable),
stat="identity",position = "identity", alpha=.3) +
scale_fill_manual(values=c("#955599", "#E63F00"))
您现在可以使用调色板 (-;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句