[R] spplot() - costumize the color-legend

Spindoctor m2m at gmx.at
Wed Mar 2 21:25:12 CET 2011


Hi!

Is there a way to manually costumize the color legend in an spplot() -
especially where to draw ticks and labels for the ticks?

The reason I'm asking: Usually spplot() automatically divides the data into
fitting slices and makes a color legend (also automatically).

I want to assign the slices myself and have a fixed scale instead of an
automatic/dynamic scale.

I think what I want gets clear in this example:

library(sp)

data(meuse.grid)
gridded(meuse.grid) = ~x+y

## DATA GENERATION
meuse.grid$random <- rnorm(nrow(meuse.grid), 7, 2) # generate random data
meuse.grid$random[meuse.grid$random < 0] <- 0 # make sure there is no value
is smaller than zero ...
meuse.grid$random[meuse.grid$random > 10] <- 10 # and bigger than ten 
## DATA GENERATION FINISHED

## making a factor out of meuse.grid$ random to have absolute values plotted
meuse.grid$random <- cut(meuse.grid$random, seq(0, 10, 0.1)) # here I assign
the levels I want to use in my plot!!!

spplot(meuse.grid, c("random"), col.regions = rainbow(100, start = 4/6, end
= 1)) # look at the color-legend - not so good.

The graphic itself is like I want it, but the legend doesn't look too good.
Although I assign 100 factors, I want just a few ticks in the legend (and
also just a few labels).

How can this be achieved?

Thank you!

--
View this message in context: http://r.789695.n4.nabble.com/spplot-costumize-the-color-legend-tp3332225p3332225.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list