我正在尝试为 3 个组绘制一个简单的散点图,每个组具有不同的水平线(线段):例如,组“a”的 hline 为 3,组“b”的 hline 为 2.5,hline 为组“b”。 “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))
Run Code Online (Sandbox Code Playgroud)
我真的很感谢你的帮助!