使用 mtext 作为标签描述与使用 xlab 的作用不同。如何使 mtext 标签始终与使用 xlab 时的大小相同(无需始终定义 cex 参数)。在下面的最小示例中,两个图的 cex=cex.lab=1 。但大小不同。
layout(matrix(c(1,1,2,2), ncol=1))
op<-par(mar=c(4,4,2,1))
plot(1:10, xlab="", ylab="", main="This is my title")
mtext("this is the x-axis", side=1, line=2.75, cex=1)
mtext("this is the y-axis", side=2, line=2.5, cex=1)
plot(1:10, xlab="this is smaller", ylab="this is smaller", main="This is my title", cex.lab=1)
par(op)
最佳答案
使用布局时,cex=1
的含义在plot
是不同的,但我不会期望这种差异会扩展到多行文本,因为它的事件在各个绘图区域之外。您可以反转“有效”中的默认减少-cex
里面plot
通过反转预期因子 2/3:
layout(matrix(c(1,1,2,2), ncol=1))
op<-par(mar=c(4,4,2,1))
plot(1:10, xlab="", ylab="", main="This is my title")
mtext("this is the x-axis", side=1, line=2.75, cex=1)
mtext("this is the y-axis", side=2, line=2.5, cex=1)
plot(1:10, xlab="this is _not_ smaller",
ylab="this is _not_ smaller, either",
main="This is my title",
cex.lab=3/2)
par(op)
进一步阅读:
?par # scroll down to mfcol, mfrow
关于r - 多行文字 : smaller labels description when layout is used,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25041893/