【问题标题】:Graphing in R program在 R 程序中绘图
【发布时间】:2013-07-04 12:17:57
【问题描述】:

所以基本上,我有这个 R 输出,我用它来制作一些折线图

    f    x  N       y           sd         se         ci         
1  Carla 1  5 0.577437500 0.538098341 0.240644894 0.668137337
2  Carla 2 21 1.975978653 3.258871642 0.711144094 1.483420586
3  Carla 3  8 1.217090357 1.936489842 0.684652549 1.618946022
4  Carla 4  6 0.004543219 0.002500954 0.001021010 0.002624590
5   Liam 1  4 0.356406250 0.203422619 0.101711309 0.323690780
6   Liam 2  8 5.164708412 5.169434477 1.827671087 4.321755376
7   Liam 3  4 0.019294020 0.002592634 0.001296317 0.004125459
8    Meg 1  3 0.337395833 0.383621255 0.221483835 0.952968025
9    Meg 2 11 2.218085777 3.889646592 1.172772574 2.613100136
10   Meg 3  3 2.239833477 3.810413346 2.199943171 9.465591491
11   Meg 4  3 0.004317894 0.002512864 0.001450803 0.006242301

我使用以下代码制作了一些折线图:

# Standard error of the mean
ggplot(dfc, aes(x=x, y=y, colour=f)) + 
    geom_errorbar(aes(ymin=y-se, ymax=y+se), width=.1) +
    geom_line() +
    geom_point()

# The errorbars overlapped, so use position_dodge to move them horizontally
pd <- position_dodge(.1) # move them .05 to the left and right

ggplot(dfc, aes(x=x, y=y, colour=f)) + 
    geom_errorbar(aes(ymin=y-se, ymax=y+se), width=.1, position=pd) +
    geom_line(position=pd) +
    geom_point(position=pd)

但我想知道是否可以“突出显示”标准错误和其他东西所占据的区域。

【问题讨论】:

  • 突出显示该区域是什么意思?填充受置信区间限制的区域(波段)?
  • 是的!这是一个更好的表达方式:D
  • 所以请编辑您的问题并澄清/准确。
  • 您的编辑让事情变得更糟,因为现在您的问题甚至没有问题。
  • Yo @Dason,我将问题添加回问题中,以便我们可以在提问时提问。莎拉:如果你想删除你的问题,请标记它们以引起版主注意。像这样屏蔽它们是没有用的。

标签: r ggplot2 area standard-error


【解决方案1】:
ggplot(dfc, aes(x=x, y=y, colour=f, fill=f, ymin=y-se, ymax=y+se)) + 
  geom_ribbon(aes(colour=NULL),alpha=0.5) +
  geom_errorbar(width=.1) +
  geom_line() +
  geom_point() 

【讨论】:

    猜你喜欢
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多