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