r - 多行文字 : smaller labels description when layout is used

标签 r plot label axis-labels par

使用 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)

enter image description here

最佳答案

使用布局时,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/

相关文章:

r - 将文本与 R 中可变大小的图对齐

swift - 文本字段 - 标签 - 按钮 根据输入回答

ios - ( swift )PrepareForSegue : fatal error: unexpectedly found nil while unwrapping an Optional value

matlab - matlab 图中的子图标签

r 如果值等于 X,则保留行和列名称

javascript - bookdown 中的代码折叠

command-line - 具有多个 "with"参数的 Gnuplot 命令

python - 如何阻止显示分辨率影响 pyqtgraph 图中的轴

r - 如何从 R/shiny 中的传单 map 获取缩放级别?

css - 如何在四开本演示文稿中更改代码块的高度和宽度