Hi! Finally i chose the plotRGB method.
Here is the code: cols <- hsv(ifelse(values(r) > .5, 0, .7), values(r), 1) cols <- col2rgb(cols) red <- r; values(red) <- cols[1, ] green <- r; values(green) <- cols[2, ] blue <- r; values(blue) <- cols[3, ] r.rgb <- stack(red, green, blue) plotRGB(r.rgb) Thanks! 2012/5/11 Barry Rowlingson <b.rowling...@lancaster.ac.uk> > On Fri, May 11, 2012 at 9:20 AM, Mathieu Rajerison > <mathieu.rajeri...@gmail.com> wrote: > > >> In col, I must specify a palette, but how can I use my color vector? > >> > >> Here is the line of code for the moment (which doesn't work): > >> cols <- hsv(ifelse(values(r) > .5, 0, .7), values(r), 1) > >> plot(r, col=topo.colors(20), axes=FALSE) > > You can do this by instead of plotting the 'r' raster (which is your > values) you plot a raster containing the values 1 to nrows*ncols. and > pass col as a vector of colours of length nrows*ncols. Then each cell > in the raster maps exactly to its colour value. > > Disadvantage: the legend is now 1:(nrows*ncols) > > The other way is to create a 3-band raster from the red, green, blue > components of the colours. > > Barry > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo