我使用以下内容绘制了两个条形图:
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图表与背景灰色相同
答案 0 :(得分:1)
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"))
您现在可以使用调色板( - ;