使用 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
的含义有所不同,但我没想到这种差异会扩展到mtext,因为它的活动位于各个绘图区域之外。您可以通过反转 2/3 的预期因子来反转 cex
内“有效”-plot
的默认减少:
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
刚刚发现您可以使用
title
代替 mtext
。
title(ylab = "this is the y-axis", line = 3.5, . . . )
我在字体缩放方面遇到了同样的问题,这样它就应该可以工作,而无需提前知道缩放系数。