开发者

Axis label placement

开发者 https://www.devze.com 2023-02-12 21:02 出处:网络
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 requ

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])
}
0

精彩评论

暂无评论...
验证码 换一张
取 消