g中的ggplot2聚类

Dou*_*oug 2 r ggplot2

有人能指出我正确的方向制作像这样的情节w/ggplot2吗?甚至只是功能类型.

我一直在ggplot2环顾四周,找不到这样的东西.

Dre*_*een 8

我假设情节的基本特征是: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()如果这很重要,您可以使用添加数字和小括号. 在此输入图像描述