【发布时间】:2017-01-28 19:22:24
【问题描述】:
我正在尝试为 3 个组绘制一个简单的散点图,每个组具有不同的水平线(线段):例如组“a”的 3 处的 hline,组“b”的 2.5 处的 hline 和组“c”在 6 处的一条线。
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))
标签: r ggplot2 line categorical-data scatter