【问题标题】:Plotting percentiles in error bars在误差线上绘制百分位数
【发布时间】:2016-03-28 09:01:01
【问题描述】:

我的这个数据包含几个数据点,以 GB 为单位的 X 值和以秒为单位的 Y 值。在这个集合之下,它是平均值、最小值和最大值,以及百分位数 5% 和 95%。这个值是在 excel 中计算出来的。我想在 R 中绘制这个图表,类似于这个one,但也有一个折线图。我在 R 中创建了这个脚本,它绘制了一个折线图,现在我需要添加误差线。我完全不知道应该如何在 R 中绘制误差线。有什么帮助吗?

1GB 2GB 4GB 8GB
225 173 695 498
332 187 310 1266
112 183 649 581
116 183 305 538
114 481 698 532
111 504 675 551
393 522 311 557
114 488 717 563
363 174 306 488
379 176 437 1348

Average 225.9   307.1   510.3   692.8619883782
Min 111 173 305 488.631612062
Max 393 522 717 1348.73486519
Percentile 95   386.7   513.9   708.45  1311.825555995
Percentile 5    111.45  173.45  305.45  493.2614168165

我的 R 脚本

add.error.bars <- function(X,Y,SE,w,col=1){
  X0 = X; Y0 = (Y-SE); X1 =X; Y1 = (Y+SE);
  arrows(X0, Y0, X1, Y1, code=3,angle=90,length=w,col=col);
}

X <- c(1,2,4,8)
meanrandom <- c(226, 307, 510, 693)

# Average
pdf(file="output.pdf") # output file
plot(X, meanrandom,xlab="Input data size (GB)", ylim=c(0,700),ylab="Makespan (seconds)", type="n", panel.first=grid(col="dimgray"))
lines(X,meanrandom,col="black",lty=1,type="o")
legend("topleft", 
       c("Random"),
       lty=c(1), # gives the legend appropriate symbols (lines)
       lwd=c(2.5),
       col=c("black"))
dev.off()

【问题讨论】:

    标签: r plot


    【解决方案1】:

    这个post 有答案。他们创建特殊的箭头来模拟误差线。

    【讨论】:

      猜你喜欢
      • 2013-02-10
      • 2014-06-02
      • 2017-01-19
      • 2020-01-23
      • 2013-03-15
      • 2018-05-10
      • 1970-01-01
      • 2016-10-19
      • 1970-01-01
      相关资源
      最近更新 更多