How can I determine the y-value of the upper plot frame border in base R
?
For example, in the plot below the y-value of the upper frame border is not 11.1
, the maximum value of ylim
. From trial and error the y-value of the upper frame border appears to be a tiny bit larger than 11.53162
which can be seen if the following line is added to the R
code below:
lines(T, rep(11.53162, length(x)), type = 'l', col = 'brown', lwd = 2, lty = 3)
How can I obtain that value from R
without using trial-and-error?
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()