[R-sig-Geo] raster::plot() common color scale?

Andy Bunn Andy.Bunn at wwu.edu
Fri Jun 10 20:01:02 CEST 2011



> -----Original Message-----
> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
> project.org] On Behalf Of Agustin Lobo
> Sent: Thursday, June 09, 2011 7:00 AM
> To: r-sig-geo; Robert J. Hijmans
> Subject: [R-sig-Geo] raster::plot() common color scale?
> 
> Hi!
> I'm doing
> 
> par(mfrow=c(2,2))
> plot(simr)
> plot(simrlisa)
> a2 = simr>l$lisamax
> plot(l$lisamax)
> plot(simr*a2)
> 
> where simr, l%lisamax and a2 are raster objects. Is there any way to
> get a common color scheme
> (i.e., setting common min and max values)?
> The color table is the same, but the scaling is independent for each
> raster object and cannot be compared.


Last time I had to do this I did something like: 

foo <- raster(nrows=20, ncols=20)
values(foo) <- runif(400)
bar <- raster(nrows=20, ncols=20)
values(bar) <- runif(400)
brks <- seq(0,1,by=0.1)
nbrks <- length(brks)-1
plot(foo,breaks=brks,col=rev(terrain.colors(nbrks)),lab.breaks=brks,zlim=c(0,1))
plot(bar,breaks=brks,col=rev(terrain.colors(nbrks)),lab.breaks=brks,zlim=c(0,1))




> 
> Thanks
> 
> Agus
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list