r / sciplot:lineplot.CI 中重叠的胡须
使用 sciplot 库中的 lineplot.CI 制作交互图时,误差线可能会在组之间重叠。例如,
data = c(1,5,3,7,3,7,5,9)
grp1 = c(1,1,1,1,2,2,2,2)
grp2 = c(1,1,2,2,1,1,2,2)
lineplot.CI(grp1, data, grp2)
通过向分组变量添加抖动并将 x.cont 设置为 TRUE,可以沿 x 轴分隔组,但这会使图中的线条消失:
data = c(1,5,3,7,3,7,5,9)
grp1 = c(1,1,1,1,2,2,2,2) + c(-0.05, -0.05, 0.05, 0.05, -0.05, -0.05, 0.05, 0.05)
grp2 = c(1,1,2,2,1,1,2,2)
lineplot.CI(grp1, data, grp2, x.cont=TRUE)
是否可以使线条出现并抖动点,以便误差线不重叠?或者有没有更好的方法来制作这种情节?
When making an interaction plot using lineplot.CI in the sciplot library, error bars can overlap across groups. For example,
data = c(1,5,3,7,3,7,5,9)
grp1 = c(1,1,1,1,2,2,2,2)
grp2 = c(1,1,2,2,1,1,2,2)
lineplot.CI(grp1, data, grp2)
The groups can be separated along the x axis by adding jitter to the grouping variable and setting x.cont to TRUE, but this makes the lines in the plot disappear:
data = c(1,5,3,7,3,7,5,9)
grp1 = c(1,1,1,1,2,2,2,2) + c(-0.05, -0.05, 0.05, 0.05, -0.05, -0.05, 0.05, 0.05)
grp2 = c(1,1,2,2,1,1,2,2)
lineplot.CI(grp1, data, grp2, x.cont=TRUE)
Is it possible to get the lines to appear and to jitter the points, so that the error bars don't overlap? Or is there a better way to make this kind of plot?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 ggplot2 来实现这一点。这是一个带有内置数据集的示例(因为我没有您的标准错误或 CI)。关键是使用
position_dodge()
。You can use ggplot2 for that. Here is an example with a built-in dataset (as I don't have your standard errors or CIs). The key is to use
position_dodge()
.