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