我用繪製在彼此的頂部的兩個柱狀圖如下:改變顏色GGPLOT2
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圖是一樣的灰色作爲背景
請仔細閱讀[如何使R中一個偉大的可重複的例子? ](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Masoud
好的,我做了一個可重複的例子@Masoud – cosmictypist
'scale_fill_manual(「legend」,我的 – Masoud