r - 使用 split.screen() 来处理不平衡的图形。整体标题位于正确位置,但经过修剪

标签 r plot

动机: 有一个包含两列的图,左列有 3 个图,右列有 4 个图,以及一个总体标题。 我可以使用 split.screen() 生成图形,并获得总体标题。但目前的问题是,整体标题没有“足够”的空间,并且其中一些被截断 - 如图所示。我尝试调整边距的大小和 .png 的大小,但没有成功。谢谢。

enter image description here

此玩具示例使用的代码:

##  Open a new default device.
get( getOption( "device" ) )()
png("Figure1.png",width = 1200,height = 1200)

par(oma = c( 0, 0, 3, 0 ) )
##  Split the screen into two rows and one column, defining screens 1 and 2.
split.screen( figs = c( 1, 2 ) )

##  Split screen 1 into one row and three columns, defining screens 3:5.
split.screen( figs = c( 3, 1 ), screen = 1 )

##  Split screen 2 into four rows and one column, defining screens 6:9.
split.screen( figs = c( 4, 1 ), screen = 2 )

screen( 3 )
plot( rnorm( n = 10 ), col = "red", main = "plot 1" )

screen( 4 )
plot( runif( n = 10 ), col = "blue", main = "plot 2" )

screen( 5 )
plot( rt( n = 10, df = 8 ), col = "springgreen4", main = "plot 3" )

screen( 6 )
plot( rpois( n = 10, lambda = 2 ), col = "black", main = "plot 4" )

screen( 7 )
plot( rf( n = 10, df1 = 4, df2 = 8 ), col = "gray30", main = "plot 5" )

screen( 8 )
plot( rf( n = 10, df1 = 4, df2 = 8 ), col = "gray30", main = "plot 6" )

screen( 9 )
plot( rf( n = 10, df1 = 4, df2 = 8 ), col = "gray30", main = "plot 7" )

##  Close all screens.
title( "Sanity Models", outer = TRUE )
close.screen( all = TRUE )
dev.off()

最佳答案

一种选择是使用它来代替当前的标题调用:

title( "Sanity Models", outer = TRUE , line=-1)

它将标题向下一行宽度放置。

关于r - 使用 split.screen() 来处理不平衡的图形。整体标题位于正确位置,但经过修剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27094658/

相关文章:

r - 将标签添加到数据表中的迷你图

r - 当我执行 lm 函数时,如何忽略 NA 数据?

r - 使用 group_by 和 case_when 为每组生成单个值

python - 为什么 pyplot.plot() 会创建一个宽度为 1、高度为 1 的附加矩形?

r - 面网格导致 R 中不同的行高

在 R 数据表中运行总和

r - 使用正弦曲线拟合的 NA 填充

r - 在 Rstudio、knitr、Rmarkdown 中没有渲染的一些图

MATLAB 简单点图

r - 如何将 colored_bars 添加到我设置 horiz=T 的 dendextend 图中