5
我想在ggplot中創建一個2變量條形圖,其中一個度量部分隱藏在另一個度量的後面。我可以使用Series Overlap在Excel中完成並獲得this result。在ggplot中調整geom_bar(position =「dodge」)
使用geom_bar(position =「dodge」)將兩個條並排放置。有沒有辦法調整這一點?
一些代碼:
library (ggplot2)
library(reshape2)
x <- c(19, 18, 21, 19)
y <- c(17, 16, 18, 19)
z <- c("a", "b", "c", "d")
df <- melt (data.frame (x,y,z))
ggplot (df, aes(x=z, y=value, fill=variable)) + geom_bar (stat="identity", position ="dodge")
我想指出的是定製的''position_dodge''量是超乎想象的。 http://ggplot2.tidyverse.org/reference/geom_bar.html – PatrickT