顯示傳說我有這樣的代碼ggplot不geom_histogram
ggplot()
+ geom_histogram(aes(x=V1, y=(..count..)/sum(..count..)), fill="red", alpha=.4, colour="red", data=coding, stat = "bin", binwidth = 30)
+ geom_histogram(aes(x=V1,y=(..count..)/sum(..count..)), fill="blue", alpha=.4, colour="blue", data=lncrna, stat = "bin", binwidth = 30)
+ coord_cartesian(xlim = c(0, 2000))
+ xlab("Size (nt)")
+ ylab("Percentage (%)")
+ geom_vline(data=cdf, aes(xintercept=rating.mean, colour=Labels), linetype="dashed", size=1)
產生一個美麗的直方圖沒有傳說:
在每一個崗位我同樣的問題參觀,他們說把color
放入aes
。不過,這並沒有給出任何傳說。
我想:
ggplot() + geom_histogram(aes(x=V1, y=(..count..)/sum(..count..),color="red", fill="red"), fill="red", alpha=.4, colour="red", data=coding, stat = "bin", binwidth = 30)
+ geom_histogram(aes(x=V1,y=(..count..)/sum(..count..), color="blue", fill="blue"), fill="blue", alpha=.4, colour="blue", data=lncrna, stat = "bin", binwidth = 30)
+ coord_cartesian(xlim = c(0, 2000))
+ xlab("Size (nt)")
+ ylab("Percentage (%)")
+ geom_vline(data=cdf, aes(xintercept=rating.mean, colour=Labels), linetype="dashed", size=1)
沒有成功。
我該如何在圖表中添加圖例?
您是否嘗試在審美映射中指定填充/顏色?我沒有看到你的代碼。一些[示例數據](http://stackoverflow.com/a/5963610/1412059)可以讓你更容易地向你展示如何做到這一點。 – Roland
什麼是審美映射? – user2979409
@ user2979409:這是您使用的'aes()'函數。 –