Hello Bart,

I also had this problem and tried a few codes to work around. I'm not an R
expert and possibly there is a simpler and better solution, but for now I
use the code below (just remove the log if it's not your scale); it's not a
perfect solution because, although the same value will receive the same
color, the scale bar will be different depending on the range of values of
each plot.

oc.plot = function(x, ...){
Colors = colorRampPalette(c("maroon3", "blue3", "royalblue1", "cyan",
"green", "yellow", "orange", "red1", "darkred"))(512)
Brks = seq(log(.01,10), log(80,10), length = 512)
Color.bar = cbind(Colors,Brks)
x[x < 0.01] = 0.01
x[x > 80] = 80
Used.colors =  Color.bar[as.numeric(Color.bar[,2]) > cellStats(log(x,
10),min) & as.numeric(Color.bar[,2]) < cellStats(log(x, 10),max),1]
plot(log(x, 10), main = "", xlab = "Longitude", ylab = "Latitude",
     zlim = c(cellStats(log(x, 10), min), cellStats(log(x, 10), max)),
     col = Used.colors, axis.args = list(at = log(c(.01, .03, .1, .3, 1,3,
10, 30, 60), 10),
                                labels = c(.01, .03, .1, .3, 1, 3, 10, 30,
60)),
                                legend.args = list(text = "[Chl-a]
(mg/m³)", side = 4,
                                line = 2.5, cex = 1))
}




2012/7/11 Bart <bart@njn.nl>

> hi
>
> I just noted that zlim does adjust the legend but not the colors causing
> the legend to not match the colors.
>
> example:
>
> require(raster)
> par(mfrow=1:2)
> plot(a<-raster(matrix(runif(**100),ncol=10)))
> plot(a, zlim=c(0,10))
>
> This is problem when one tries to create multiple plots with a matching
> legend.
>
> I'm not sure if zlim is suppose to work but i think it should then issue a
> warning or error but not plot something with a wrong legend
>
> Bart
>
> ______________________________**_________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>



-- 
Alexandre Castagna Mourão e Lima
Laboratório de Radioecologia e Mudanças Globais - UERJ
Rua São Francisco Xavier, 524, Maracanã
Pav. Haroldo Lisboa da Cunha, Sub-solo

	[[alternative HTML version deleted]]

