[英]R plot: adding a title to the y-axis
I would like to add a title for the y-axis of the top plot. 我想为顶部图的y轴添加标题。 Of course, in the toy example below, I can use the ylab argument.
当然,在下面的玩具示例中,我可以使用ylab参数。 But I am looking for another option to fit with my actual problem.
但是我正在寻找另一种选择来解决我的实际问题。 It appears that mtext() does not do the job in this case.
在这种情况下,似乎mtext()不能完成任务。 Any other idea?
还有其他想法吗?
x11()
par(mfrow=c(2, 1))
plot(1:10, ylab = " ")
mtext(text = "y-label", side = 2, line = -2, outer = TRUE)
plot(1:10, ylab = " ")
mtext(text = "y-label", side = 2,line=2, at=26, outer = FALSE)
You will have to play around where at=
is to find the sweet spot for both graphs but this will do what you are asking. 您将不得不在
at=
位置上找到两个图的最佳位置,但这将满足您的要求。 6 seems to be a good number for the bottom graph if anything. 如果有的话,对于底部图形来说6似乎是个好数字。 (Using the example)
(使用示例)
If you imagine line
to be an x co-ordinate and at
to be ay co-ordinate then you can just play around until you find what fits. 如果你想像
line
是一个x坐标,并at
为AY统筹那么你可以玩,直到你找到最适合。
Probably not as clean and cut as you wanted but it will work. 可能不是您想要的那样干净整洁,但是它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.