我正在尝试使用包layout
的函数graphics
在R中设置复杂的图形排列。
x <- y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))
当我只使用使用函数image
创建的图时,事情按预期工作,如此处所示
M=matrix(c(1,2,3,4,5,4),3,2, byrow=T)
M
layout(M)
layout.show(5)
image(z = r, main="plot1")
image(z = r, main="plot2")
image(z = r, main="plot3")
image(z = r, main="plot4")
image(z = r, main="plot5")
dev.off()
然而,当我尝试使用image.plot
时,为了获得色标,不再遵循布局,如此处所示
layout(M)
layout.show(5)
library(fields)
image.plot(z = r, main="plot1")
image.plot(z = r, main="plot2")
image.plot(z = r, main="plot3")
image.plot(z = r, main="plot4")
image.plot(z = r, main="plot5")
dev.off()
我怀疑这个问题可能来自于image.plot
划分绘图区域的事实。我也尝试过使用split.screen
,这似乎效果更好,但我更喜欢使用layout
,这对于非常复杂的安排可能更容易。