[R] Custom colourkey spacing in levelplot, contourplot

Frede Aakmann Tøgersen FredeA.Togersen at agrsci.dk
Tue Oct 23 13:59:09 CEST 2007

How about

mbreaks <- c(0,0.001,0.01,0.1,1,10)
          colorkey=list(at=1:length(mbreaks),labels = list(labels=mbreaks)))


Med venlig hilsen
Frede Aakmann Tøgersen


> -----Oprindelig meddelelse-----
> Fra: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] På vegne af 
> r-help.20.trevva at spamgourmet.com
> Sendt: 23. oktober 2007 13:28
> Til: r-help at stat.math.ethz.ch
> Emne: [R] Custom colourkey spacing in levelplot, contourplot
> Dear R gurus,
> I have got stuck on how to customise the colorkey generated 
> by levelplot and contourplot, in the lattice package. This 
> best illustrated by an example:
> library(lattice)
> levelplot(volcano^20/1e45,at=c(0,0.001,0.01,0.1,1,10))
> The reason for raising the volcano dataset to the 20th power 
> is to create a dataset with a large vertical exaggeration - 
> this is similar in nature to the data set that I am dealing 
> with. Now, if you look at the colorkey to the right of the 
> plot, you'll see that its basically dominated by the interval 
> 1:10, and that the 0.001:0.01 color is virtually invisible, 
> even though it makes up quite a decent fraction of the actual 
> plot (its the light pink/lavendar colour between the white 
> and the magenta) .
> So the question is, how can I customise the colourkey so that 
> it consists of five, equally spaced colour intervals, with 
> the appropriate annotation - in this case I am essentially 
> try to have a logarithmic distribution of the ticks, but you 
> can imagine that there will be cases when one wants something 
> completely custom.
> Cheers,
> Mark
> ______________________________________________
> 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.

More information about the R-help mailing list