R 结合geom_箱线图和geom_线
我想使用R 结合geom_箱线图和geom_线,r,ggplot2,R,Ggplot2,我想使用ggplot2组合箱线图和线图。然而,我很难为每个组(g)在x轴上的类别上建立连接点 要演示问题,请执行以下操作: df <- data.frame(x = rep(letters[1:3],each=5), y = c(1:5,sample(10,5),1:5), g = rep(LETTERS[1:5],3) ) library(ggplot2) ggplot(df, aes(x=x,y=y)) + ge
ggplot2
组合箱线图和线图。然而,我很难为每个组(g
)在x轴上的类别上建立连接点
要演示问题,请执行以下操作:
df <- data.frame(x = rep(letters[1:3],each=5),
y = c(1:5,sample(10,5),1:5),
g = rep(LETTERS[1:5],3) )
library(ggplot2)
ggplot(df, aes(x=x,y=y)) + geom_boxplot() + geom_point(aes(colour = g))
df添加geom_线(aes(group=g))
做你想做的事吗?它确实是一个很酷的形状…在你的示例代码中添加一个集合。seed
,这样我们就可以在你调用sample
@Justin,aw-man时准确地复制你的图像,我正在使用geom_-line(aes(color=g))
,而ggplot出现问题。你的建议解决了问题。事实上,它也能做出很酷的形状。
... + geom_line(aes(group = g))