r - 调整基础 R 中的情节标题和副标题

标签 r

如何获得基础 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")

r_titles

最佳答案

根据 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() 选项,以便有足够的空间将标题放置在对图上方。

这是情节:
enter image description here

关于r - 调整基础 R 中的情节标题和副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55002046/

相关文章:

c# - 从 C#/.NET 将数据表返回到 R

r - 增加样本数据的大小 - R

r - 使用 count() 和 factor() 函数时,如何在 R ggplot 中使用动态声明的变量?

r - 是否有导出当前图的命令?

r - 检查 R 数据帧 : if it does keep the values, 中是否存在变量(如果未设置为 NA)

r - 在ggplot2中叠加条形图

使用 R 中的条件从列表中的每个数据框中删除行

r - 在 R 中没有重复组星座的子组中对多个个体进行采样

r - 在 ggplot2 的 stat_density2d 中指定密度的比例

r - 如何使用 purrr 和 Pipes 顺序应用函数