根据多个因素绘制箱线图,并使用ggplot2覆盖R中的原始数据

根据多个因素绘制箱线图,并使用ggplot2覆盖R中的原始数据,r,ggplot2,boxplot,R,Ggplot2,Boxplot,我有一个这样的箱线图 library(ggplot2) p <- ggplot(mtcars, aes(factor(cyl), mpg)) p + geom_boxplot(aes(fill = factor(am))) 库(ggplot2) p您需要将点定位为geom\u箱线图的默认值: ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(am))) + geom_boxplot() + geom_point(positi

我有一个这样的箱线图

library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(aes(fill = factor(am)))
库(ggplot2)

p您需要将点定位为
geom\u箱线图的默认值:

ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(am))) + 
  geom_boxplot() + 
  geom_point(position = position_dodge(width = .7))

好的,谢谢!我在CrossValidated上发现了这一点:并认为这将是一个自然的后续行动!太好了,谢谢!你还可以将位置抖动和位置抖动结合起来吗?我想你必须解决这个问题-例如,啊,不知道
位置抖动()。酷。:-)
ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(am))) + 
  geom_boxplot() + 
  geom_point(position = position_dodge(width = .7))