我想绘制3组的简单散点图,每组有不同的水平线(线段):例如,对于组“a” ,对于组“b”为2.5,对于组“c”为6。使用ggplot2在R中添加分类散点图中的水平线
library(ggplot2)
df <- data.frame(tt = rep(c("a","b","c"),40),
val = round(rnorm(120, m = rep(c(4, 5, 7), each = 40))))
ggplot(df, aes(tt, val))+
geom_jitter(aes(tt, val), data = df, colour = I("red"),
position = position_jitter(width = 0.05))
我真的很感谢您的帮忙!
尝试是这样的:'geom_segment(AES(X = 0.75,xend的= 1.25,Y = 3,YEND = 3))' –