[R-sig-Geo] Same color scale
Oscar Perpiñan Lamigueiro
oscar.perpinan at upm.es
Tue Nov 22 23:59:42 CET 2011
Hi,
Perhaps the levelplot method from rasterVis is useful to solve this
problem.
library(rasterVis)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
s <- stack(r, r-maxValue(r))
levelplot(s, par.settings=RdBuTheme)
If you need separate pages for each map you can use:
trellis.device(pdf, file='test.pdf')
levelplot(s, par.settings=RdBuTheme, layout=c(1, 1))
dev.off()
Best,
Oscar.
El Tue, 22 Nov 2011 14:56:31 +0100
alain.reymond at wsl.ch escribió:
> Dear all,
> I want to compare 2 raster data map where probability values between
> 0 and 1 are not the same (different mix-max values). For this I want
> to apply to both map the same color scale (i.e. 0-0.1 red, 0.1-0.2
> blue etc.) in an automatic way without doing it individually for each
> map.
>
> I have tried many ways :
> - reclassifying the probability. But here the problem is if one class
> do not exist the color will shift and I cannot assign a particular
> color to a particular class to avoid this.
>
> - rewriting the breaks limits (sequence from 0 to 1 by 0.1) and using
> the RampPalette but it did not work either because of the max-value
> of the data (they are not the same and not in the same sequence) and
> one color will be add in the rampPalette to fill in the difference.
> It looks like as in the rampPalette there is like a defined min-color
> and max-color and it will add as many as needed between those 2.
> Therefore I wrote by hand some color for the sequence and it worked
> but I had to delet colors to adapt to the max number of really
> existing sequence. Hence, if I want to do this for a lot of files I
> can't make it that way.
>
> - I also used the ggplot, but again, there is a min-color and a
> max-color for the min and max values (i.e. blue-red). If one ggplot
> has more sequence than the other one, in both case they will have the
> blue and red as min and max color but then not the same number of
> color between those 2. And If I do not set a max-color (or any min
> and max color) it does not work either.
>
> I already thank you if you have any solution to my problem that could
> be used "easily" without having to write specific color for each map.
> Best,
>
> Alain
>
>
>
>
> =
> [[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list