[R-sig-Geo] Resent: colorkey: Placement of labels and ticks in center positions of "color key" of a levelplot ?

Edzer Pebesma e.pebesma at gmail.com
Thu Dec 24 16:21:57 CET 2009


Dear Zia,

try as an example

library(sp)
data(meuse.grid)
gridded(meuse.grid) = ~x+y
meuse.grid$f = as.factor(meuse.grid$part.a)
spplot(meuse.grid, "f")

so, this works for spplot, by default, but only for factors.

You can find out from the sp sources how this works. Please note that on
r-help, few people will understand where you found meuse.grid.

A merry christmas to everyone,
--
Edzer

Zia Ahmed wrote:
> Is it possible to place  labels  and ticks  in center positions of 
> each cut of  "color key" of levelplot ? Here is my code that I used to 
> produce a map (see attachment). The two  labels and ticks  were  
> placed  in  left  sides each segment of the color key. I want to show 
> them center of the cuts.
> Help will be appreciated.
> Thanks
>
> Zia
>
> windows(width=4, height=5)
> jpeg( file="/////Fig_1.jpg",
> units = "px", pointsize = 12, quality = 75, bg = "white",
> res = NA, restoreConsole = TRUE)
>
> levelplot(ffreq~x+y, aspect="iso",
>            xlab=list("E (m)",cex=.6), ylab="N (m)",
>            scales=list(y=list(draw=T,cex=.7,rot=90, tck= 
> .35),x=list(draw=T, cex=.7,tck= .35)),
>             colorkey = list(space="right",tick.number=1,height=1, 
> width=1.5,
>             labels = list(at = seq(1,2,length=2),cex=.7,rot=90,
>             lab = c("annual", "2-5 years"))),
> # I want place above labels center of each cuts of colorkey"
>             as.data.frame(meuse.grid),
>             col.regions=gray.colors,cuts=1,
>             panel = function(...) {
>             panel.levelplot(...)
>             panel.grid(h=-1, v=-1, col="darkgrey")
>                 }, )
> dev.off()
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>   

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list