I've got a probably fairly simple question. I want to put my y-axis label horizontally above the y-axis, in stead of the default (vertically alo开发者_Python百科ngside the y-axis). This probably requires a par() command, but which one?
thanks in advance!
I don't think par
is what you want. You could just adjust the default, exclude the label of the y-axis with ylab = ""
and manually add your text with marginal text input (mtext
).
Example:
xx <- 1:20
yy <- 55 + 50 * xx - 3 * xx ^ 2
plot(x = xx, y = yy, type = "l", ylab="")
mtext("yy", side = 3, at = -1)
Or as a function:
newplot <- function(xx, yy) {
plot(x = xx, y = yy, type = "l", ylab="")
mtext(deparse(substitute(yy)), side = 3,
at = - sum(range(xx)) / range(xx)[2])
}
精彩评论