我正在绘制一些图形,这些图形在两个组之间具有重叠的点,这些点被躲避以使组清晰。在两个实验条件下(显示在x轴上)显示了组中的一个点,我想用线将这两组点连接起来。我也想通过填充均值并使各个数据点为空来区分均值和数据点。基本上,即使我也躲避线条,也无法让我的“躲避”点与线条整齐地结合在一起。
使用示例数据的示例:
group <- c("high", "high", "high", "low", "low", "low", "high", "high", "high", "low", "low", "low")
condition <- c("c1", "c1", "c1", "c1", "c1", "c1", "c2", "c2", "c2", "c2", "c2", "c2")
value <- c(.91, .63, .5, NA, NA, NA, .93, .76, .43, .5, .6, .8)
subj <- c("s1", "s2", "s3", "s4", "s5", "s6")
sample.data <- data.frame(group, condition, value, subj)
ggplot(sample.data, aes(x=condition, y=value)) +
geom_point(aes(colour=group, shape = group), size = 2, position = position_dodge(.1)) +
scale_shape_manual(values=c(2,1)) +
geom_line(aes(group=subj), colour='lightgrey') +
stat_summary(fun.y=mean, geom = "point", aes(shape=group, fill = group),
size=5, position = position_dodge(.1)) +
stat_summary(fun.y = mean, aes(group=group, colour=group), geom='line',
size=.8, position = position_dodge(.1))
如您在示例图中看到的那样,即使我也“躲避了”这条线,但这些线并没有将这些点连接起来。有一种让ggplot做到这一点的好方法吗?
非常感谢!