如何减少多图布局的列之间的空space?
How to reduce the empty space between the columns of a multiple plot layout?
同一行的两个地块之间有很多空白 space。我试图通过使用 par() 更改外边距和绘图边距来纠正此问题,但它不起作用。我想到的另一个解决方案是增加单个地块的大小,但我不知道该怎么做。
layout(matrix(1:8, ncol=2, byrow=TRUE))
par(oma=c(5,0.1,1,1), mar=c(5,0.1,1,1), pty="s")
plot(Annual.Rainfall.in.mm ~ Year, data=AnnRF, ylab = "Rainfall (mm)", sub="(a)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(AnnRF$Year, AnnRF$Annual.Rainfall.in.mm), col="red", lwd=3)
plot(Annual.Rainy.Days ~ Year, data=AnnRD, ylab = "Rainy Days", sub="(b)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(AnnRD$Year, AnnRD$`Annual.Rainy.Days`), col="red", lwd=3)
plot(Monsoon.Rainfall.in.mm ~ Year, data=MonRF, ylab = "Rainfall (mm)", sub="(c)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(MonRF$Year, MonRF$`Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Monsoon.Rainy.Days ~ Year, data=MonRD, ylab = "Rainy Days", sub="(d)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(MonRD$Year, MonRD$`Monsoon.Rainy.Days`), col="red", lwd=3)
plot(Pre.Monsoon.Rainfall.in.mm ~ Year, data=PreRF, ylab = "Rainfall (mm)", sub="(e)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PreRF$Year, PreRF$`Pre.Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Pre.Monsoon.Rainy.Days ~ Year, data=PreRD, ylab = "Rainy Days", sub="(f)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PreRD$Year, PreRD$`Pre.Monsoon.Rainy.Days`), col="red", lwd=3)
plot(Post.Monsoon.Rainfall.in.mm ~ Year, data=PostRF, ylab = "Rainfall (mm)", sub="(g)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PostRF$Year, PostRF$`Post.Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Post.Monsoon.Rainy.Days ~ Year, data=PostRD, ylab = "Rainy Days", sub="(h)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PostRD$Year, PostRD$`Post.Monsoon.Rainy.Days`), col="red", lwd=3)
您可以通过控制图像的整体宽度和高度来保存绘图,即绘图页面大小,例如,作为 png 文件。
参数 pty = "s"
强制使用方形图。因此,通过调整绘图页面大小的宽度和高度参数,您可以获得所需的外观。
或者,您可以使用 layout
的 respect
参数并使用 cex.lab
来改变轴标签大小。
layout(matrix(1:8, ncol=2, byrow=TRUE), respect = TRUE)
par(oma=c(0, 0, 0, 0),
mar=c(5,4,1,1),
pty="s")
for(i in 1:8) plot(iris$Sepal.Length, iris$Petal.Length, sub = i,
cex.lab = 1.5)
同一行的两个地块之间有很多空白 space。我试图通过使用 par() 更改外边距和绘图边距来纠正此问题,但它不起作用。我想到的另一个解决方案是增加单个地块的大小,但我不知道该怎么做。
layout(matrix(1:8, ncol=2, byrow=TRUE))
par(oma=c(5,0.1,1,1), mar=c(5,0.1,1,1), pty="s")
plot(Annual.Rainfall.in.mm ~ Year, data=AnnRF, ylab = "Rainfall (mm)", sub="(a)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(AnnRF$Year, AnnRF$Annual.Rainfall.in.mm), col="red", lwd=3)
plot(Annual.Rainy.Days ~ Year, data=AnnRD, ylab = "Rainy Days", sub="(b)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(AnnRD$Year, AnnRD$`Annual.Rainy.Days`), col="red", lwd=3)
plot(Monsoon.Rainfall.in.mm ~ Year, data=MonRF, ylab = "Rainfall (mm)", sub="(c)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(MonRF$Year, MonRF$`Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Monsoon.Rainy.Days ~ Year, data=MonRD, ylab = "Rainy Days", sub="(d)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(MonRD$Year, MonRD$`Monsoon.Rainy.Days`), col="red", lwd=3)
plot(Pre.Monsoon.Rainfall.in.mm ~ Year, data=PreRF, ylab = "Rainfall (mm)", sub="(e)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PreRF$Year, PreRF$`Pre.Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Pre.Monsoon.Rainy.Days ~ Year, data=PreRD, ylab = "Rainy Days", sub="(f)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PreRD$Year, PreRD$`Pre.Monsoon.Rainy.Days`), col="red", lwd=3)
plot(Post.Monsoon.Rainfall.in.mm ~ Year, data=PostRF, ylab = "Rainfall (mm)", sub="(g)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PostRF$Year, PostRF$`Post.Monsoon.Rainfall.in.mm`), col="red", lwd=3)
plot(Post.Monsoon.Rainy.Days ~ Year, data=PostRD, ylab = "Rainy Days", sub="(h)", col="blue", bg="blue", pch=21, cex.lab = 1.4)
lines(lowess(PostRD$Year, PostRD$`Post.Monsoon.Rainy.Days`), col="red", lwd=3)
您可以通过控制图像的整体宽度和高度来保存绘图,即绘图页面大小,例如,作为 png 文件。
参数 pty = "s"
强制使用方形图。因此,通过调整绘图页面大小的宽度和高度参数,您可以获得所需的外观。
或者,您可以使用 layout
的 respect
参数并使用 cex.lab
来改变轴标签大小。
layout(matrix(1:8, ncol=2, byrow=TRUE), respect = TRUE)
par(oma=c(0, 0, 0, 0),
mar=c(5,4,1,1),
pty="s")
for(i in 1:8) plot(iris$Sepal.Length, iris$Petal.Length, sub = i,
cex.lab = 1.5)