I'm generating multiple plots with command image
image(X,Y,MAT,col=heat.colors(100))
this command is in a for cycle, where X, Y and MAT change.
How can I have the same colour scale for all the plots (I have to compre them)? How can I set a common colour scale (I have the maximum and minimum value beteen all plots)?
Thanks
Feed the overall maximum and minimum values of MAT over all loop iterations into the zlim parameter of image.
set.seed(1)
xx <- sort(rnorm(10))
yy <- sort(rnorm(10))
zz <- list(matrix(rnorm(100),nrow=10,ncol=10),matrix(rnorm(100)-2,nrow=10,ncol=10))
par(mfrow=c(1,2))
image(xx,yy,z=zz[[1]],col=heat.colors(100))
image(xx,yy,z=zz[[2]],col=heat.colors(100))

image(xx,yy,z=zz[[1]],col=heat.colors(100),zlim=range(unlist(zz)))
image(xx,yy,z=zz[[2]],col=heat.colors(100),zlim=range(unlist(zz)))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With