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

From: Spindoctor <m2m_at_gmx.at>
Date: Wed, 02 Mar 2011 12:25:12 -0800 (PST)


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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 02 Mar 2011 - 20:33:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Mar 2011 - 16:50:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive