上图框的y值

时间:2017-11-23 07:58:50

标签: r plot

如何确定基础R中上方图框边框的y值?

例如,在下图中,上框边框的y值不是11.1ylim的最大值。从试验和错误开始,上框边框的y值似乎比11.53162稍微大一点,如果将以下行添加到下面的R代码中,可以看到该值:

 lines(T,  rep(11.53162, length(x)), type = 'l', col = 'brown', lwd = 2, lty = 3)

如何在不使用反复试验的情况下从R获取该值?

T   <- 1:10
x   <- 5 + 0.5 * T
x.u <- 6 + 0.5 * T
x.l <- 4 + 0.5 * T

jpeg('my_plot.jpg')

c(0, (max(x.u)+0.1))
# 0.0 11.1

plot(T, x, xlab = 'x', ylab = 'y', type = 'l', col = 'green', lwd = 2, lty = 1,

     ylim = c(0, (max(x.u)+0.1)), cex.lab = 1.5)
     lines(T,  x.u, type = 'l', col = 'brown', lwd = 2, lty = 3)
     lines(T,  x.l, type = 'l', col = 'brown', lwd = 2, lty = 3)
     lines(T,  rep(11.1, length(x)), type = 'l', col = 'brown', lwd = 2, lty = 3)

dev.off()

enter image description here

0 个答案:

没有答案