[英]Move title of plots in a list of plots in R
I have a list of plots that I have assigned names to, and then converted to plot titles as suggested by https://stackoverflow.com/a/14790376/9335733 . 我有一个分配了名称的地块列表,然后按照https://stackoverflow.com/a/14790376/9335733的建议将其转换为地块标题。 The titles happen to appear over the top x-axis title and so I attempt to move them as suggested here: https://stackoverflow.com/a/44618277/9335733 .
标题恰好出现在顶部的x轴标题上方,因此我尝试按照此处的建议将其移动: https : //stackoverflow.com/a/44618277/9335733 。 The overall code looks as follows:
总体代码如下:
lapply(names(Cast.files), function (x) plot(Cast.files[[x]],
main = x,
adj = 0, #adjust title to the farthest left
line =2.5 #adjust title up 2.5
)
)
It should be noted that plot
is now converted from base R to the oce
package for analyzing oceanographic data, but calls the same arguments from base R plot
. 应当注意的是,
plot
,现在从基础R转换为oce
包用于分析海洋数据,但要求从基础R相同的参数plot
。
The problem becomes that in trying to move the title, the axis labels move as well and overlap. 问题在于,在尝试移动标题时,轴标签也会移动并重叠。 Any suggestions?
有什么建议么?
Edit: Here is what the image looks like before: 编辑:这是图像之前的样子:
You might also want to look into the oma=
argument in par()
, which provides an "outer" margin which can be used to put a nice title. 您可能还想研究
par()
的oma=
参数,该par()
提供了“外部”边距,可用于放置漂亮的标题。 Something like: 就像是:
library(oce)
data(ctd)
par(oma=c(0, 0, 1, 0))
plot(ctd)
title('Title', outer=TRUE)
This was solved by adding a title
argument outside of the plot
function as follows: 这是通过在
plot
函数之外添加title
参数来解决的,如下所示:
lapply(names(Cast.files), function (x) plot(Cast.files[[x]],
which = c("temperature", "salinity", "sigmaT","conductivity"),
Tlim = c(11,12),
Slim = c(29,32),
col = "red")
+ title(main = x, adj = 0.48, line = 3.5)#adding the titles at a specific location
)
This allowed for plots that looked like: 这允许如下图所示:
如果您使用标题功能,而不是在绘图中设置main,则可以在不影响绘图中任何其他内容的情况下更改行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.