我想創建一個看起來像this的圖。經過一番思考,我創建了一個虛擬數據幀,我認爲可能是有點類似於我需要什麼:R和ggplot2:如何創建一個包含三個元素的圖形?
dum = structure(list(pan = c(4000, 5000, 6000, 7000, 8000, 9000), core = c(1000, 2000, 3000, 2500, 2600, 2700), Group = c("Bac1", "Bac2", "Bac3", "Bac4", "Bac5", "Bac6"), Strain = c(1000L, 50L, 25L, 10L, 25L, 10L)), .Names = c("pan", "core", "Group", "Strain"), row.names = c(NA, -6L), class = "data.frame")
我一直在使用這種代碼:
ggplot(dum, aes(x=Group,y = Strain)) +
geom_bar(stat = "identity") +
geom_line(aes(y = pan, colour = "pan")) +
geom_line(aes(y = core, colour = "core"))
將會產生這種不正確的graph 。
這裏怎麼回事?我不明白爲什麼圖表的核心元素沒有顯示出來。他們是否被geom_bar
命令否定?
喂@ E.O。如果解決方案是好的,你能標記它嗎?謝謝。 – Umberto