Use of image.plot with specific layout

Viewed 352

I am trying to set up a complex arrangement of graphs in R, using the function layout of the package graphics.

x <- y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))

When I only use plots created with the function image, things work as expected as shown here

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()

However, when I try to use image.plot, to get the color scale, the layout is not followed anymore, as shown here

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()

I suspect the issue may come from the fact that image.plot divides the plotting region. I have also tried using split.screenand this seems to work better but I would prefer using layout which may be easier for very complex arrangements.

0 Answers
Related