[R-sig-Geo] spplot: title for the colorkey

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jan 3 18:22:09 CET 2012


Roman, spplot is a wrapper around lattice::xyplot when the object is
points, and around lattice::levelplot when it is lines, polygons or
raster (grid/pixels). The original question was for raster data, and
levelplot does not have an auto.key argument. Indeed, only for points
this works.

On 01/03/2012 06:16 PM, Roman Luštrik wrote:
>  Hi Renaud,
> 
> If you check out the levelplot function in lattice (as per Edzer), you will
> notice there's an auto.key argument. It takes in a named list of arguments,
> one of them being title. I use spplot example to demonstrate how to put a
> "test" title over the key.
> 
> library(lattice)
> trellis.par.set(sp.theme()) # sets bpy.colors() ramp
> data(meuse)
> coordinates(meuse) <- ~x+y
> l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset =
> c(181300,329800),
>  scale = 400)
> l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset =
> c(180500,329800),
>  scale = 500, fill=c("transparent","black"))
> l4 = list("sp.text", c(180500,329900), "0")
> l5 = list("sp.text", c(181000,329900), "500 m")
> 
> spplot(meuse, c("ffreq"), sp.layout=list(l2,l3,l4,l5), col.regions=
> "black",
>  pch=c(1,2,3), key.space=list(x=0.1,y=.95,corner=c(0,1)), auto.key =
> list(title = "test"))
> 
> 
> I hope that works for your plot as well.
> 
> Cheers,
> Roman
> 
> 
> On Tue, Jan 3, 2012 at 5:43 PM, Edzer Pebesma <edzer.pebesma at uni-muenster.de
>> wrote:
> 
>> Not that I know of; see argument colorkey in ?lattice::levelplot.
>>
>> On 12/30/2011 11:38 PM, lancelot wrote:
>>> Dear all,
>>>
>>> Is there a simple way to add a title to the color key produced by spplot
>>> (package sp) for raster data sets?
>>>
>>> Best wishes,
>>>
>>> Renaud
>>
>> --
>> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 
> 
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> 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