如何获得基础 R 绘图标题和副标题以模仿 ggplots?我希望所有内容都左对齐,没有粗体,副标题直接在标题下方。
我还想在所有东西之间留出更多空间。也许我的换行符 \n
'hack' 是实现此目的的最佳方法?
plot(mtcars)
title(main = "I want main title NOT bold and left aligned\n\n",
sub = "Sub title should be under the main title left aligned")
最佳答案
根据 Cettt 的建议,如何使用 mtext
如下:
plot(mtcars, oma=c(2, 3, 5, 2))
mytitle = "I want main title NOT bold and left aligned"
mysubtitle = "Sub title should be under the main title left aligned"
mtext(side=3, line=3, at=-0.07, adj=0, cex=1, mytitle)
mtext(side=3, line=2, at=-0.07, adj=0, cex=0.7, mysubtitle)
adj=0
选项请求左对齐。line=
选项定义每个标题的垂直位置,从绘图上边缘的边界向外计数。您可以使用
at=
选项根据需要水平移动标题。还要注意在
oma=
调用中使用 plot()
选项,以便有足够的空间将标题放置在对图上方。这是情节:
关于r - 调整基础 R 中的情节标题和副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55002046/