在ggplot中调整geom_bar(position =“dodge”)

前端之家收集整理的这篇文章主要介绍了在ggplot中调整geom_bar(position =“dodge”)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在ggplot中创建一个2变量条形图,其中一个度量部分隐藏在另一个之后.我可以使用Series Overlap在Excel中完成它并获得 this result.

使用geom_bar(position =“dodge”)将两个条并排放置.有没有办法调整这个?

一些代码

library (ggplot2)
library(reshape2)
x <- c(19,18,21,19)
y <- c(17,16,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")
@H_404_9@解决方法
您可以通过指定position = position_dodge(…)来自定义闪避.
ggplot (df,fill=variable)) + 
  geom_bar (stat="identity",position = position_dodge(width = 0.5))
原文链接:https://www.f2er.com/css/214777.html

猜你在找的CSS相关文章