equal spacing of the polygons in levelplot key (lattice)
-----Original Message----- From: Dennis Murphy [mailto:djmuser at gmail.com] Sent: Tuesday, November 15, 2011 8:54 PM To: Andy Bunn Cc: r-help at r-project.org Subject: Re: [R] equal spacing of the polygons in levelplot key (lattice) Hi: Does this work?
Thanks Dennis. This almost works. Is there a way to make the rectangles in the key the same size? In this example five rectangles of the same area evenly arrayed? Can the key be coerced into being categorical? The data I want to work with are not spatial but it occurs to me that this is a common mapping task (e.g., in this example you might want to label these colors 'low', 'kind of low', 'medium low', etc. or map land covers or such.) I'll look at the sp or raster plotting equivalent.
# library('lattice')
levs <- as.vector(quantile(volcano,c(0,0.1,0.5,0.9,0.99,1)))
levelplot(volcano, at = levs,
colorkey = list(labels = list(at = levs,
labels = levs) ))
HTH,
Dennis
On Tue, Nov 15, 2011 at 1:12 PM, Andy Bunn <Andy.Bunn at wwu.edu> wrote:
Given the example: R> (levs <- quantile(volcano,c(0,0.1,0.5,0.9,0.99,1))) ? 0% ?10% ?50% ?90% ?99% 100% ? 94 ?100 ?124 ?170 ?189 ?195 R> levelplot(volcano,at=levs) How can I make the key categorical with the size of the divisions
equally spaced in the key? E.g., five equal size rectangles with labels at levs c(100,124,170,189,195)?
Apologies if this is obvious. -A R> version ? ? ? ? ? ? ? ?_ ?platform ? ? ? i386-pc-mingw32 ?arch ? ? ? ? ? i386 ?os ? ? ? ? ? ? mingw32 ?system ? ? ? ? i386, mingw32 ?status ?major ? ? ? ? ?2 ?minor ? ? ? ? ?14.0 ?year ? ? ? ? ? 2011 ?month ? ? ? ? ?10 ?day ? ? ? ? ? ?31 ?svn rev ? ? ? ?57496 ?language ? ? ? R ?version.string R version 2.14.0 (2011-10-31)
______________________________________________ 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.