我假设情节的基本特征是:a.)x轴是分类的,b.)点的x位置略有变化,c.)一些汇总统计(我用中位数) .如果那就是你要找的东西,
require(ggplot2)
require(plyr)
#define the data
lev <- gl(2, 10, 20, labels=c("I", "II"))
y <- runif(20)
df <- data.frame(lev, y)
#calculate the medians - I'm guessing that's what the horiz lines are?
meds <- ddply(df, .(lev), summarise, med = median(y))
ggplot(df, aes(x=lev, y=y, colour=lev)) +
geom_point(position="jitter") +
theme_bw() +
scale_colour_manual(values=c("red", "darkblue")) +
geom_errorbar(data=meds, aes(x=lev, y=med, ymin=med, ymax=med))
Run Code Online (Sandbox Code Playgroud)
annotate()
如果这很重要,您可以使用添加数字和小括号.