R、 按比例绘制布局图

R、 按比例绘制布局图,r,legend,figure,R,Legend,Figure,我正在寻找一种将四个区域放入矿区的方法,该区域将具有以下矩阵的逻辑: > matrix(data=c(1,3,2,4),nrow=2,byrow=TRUE) [,1] [,2] [1,] 1 3 [2,] 2 4 单元格1:将是较大的数字。真实的情节到处都包含信息,因此添加的图例会阻碍更多的内容 单元格2:将仅包含图1的图例 单元3:图2 单元4:图3 理想情况下,我希望单元格1的高度为70%,图例仅为30%,而三个和四个单元格的可用高度相同 到目前为止

我正在寻找一种将四个区域放入矿区的方法,该区域将具有以下矩阵的逻辑:

> matrix(data=c(1,3,2,4),nrow=2,byrow=TRUE)
     [,1] [,2]
[1,]    1    3
[2,]    2    4
单元格1:将是较大的数字。真实的情节到处都包含信息,因此添加的图例会阻碍更多的内容 单元格2:将仅包含图1的图例 单元3:图2 单元4:图3

理想情况下,我希望单元格1的高度为70%,图例仅为30%,而三个和四个单元格的可用高度相同

到目前为止,我已经找到了布局函数,并创建了一些可复制的代码

layout(matrix(data=c(1,3,2,4),nrow=2,byrow=TRUE))
# Figure 1
plot(runif(1000))
#Figure 2 actually is only the legend that does not fit below Figure 1, for my case
plot.new()
legend("bottom",legend="THis is a very big string that will not fit with the Figure above so it has to be below the Figure")
# Figure 3
plot(runif(1000))
# Figure 4
plot(runif(1000))
这段代码创建了一个具有四个区域的图形,不幸的是,我无法根据需要设置比例。尽管我可以使用layout命令设置宽度和高度,但它们对整行有效,而不是像我需要的那样单独设置

对于如何进一步调整此代码,是否有任何建议

我想提前感谢你的回复 当做
Alex

您的矩阵定义不清楚。对于你想要的比例,类似这样的东西会起作用(你可以玩得更多以获得准确的比例):

layout(matrix(c(1,1,3,3,1,1,3,3,1,1,4,4,2,2,4,4), nrow = 4, ncol = 4, byrow = TRUE))
# Figure 1
plot(runif(1000))
#Figure 2 actually is only the legend that does not fit below Figure 1, for my case
plot.new()
legend("bottom",legend="THis is a very big string that will not fit with the Figure above so it has to be below the Figure")
# Figure 3
plot(runif(1000))
# Figure 4
plot(runif(1000))