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

lancelot renaud.lancelot at cirad.fr
Tue Jan 3 19:41:05 CET 2012


Yes, indeed. Thank your for your time and suggestions.

Renaud

Le 03/01/2012 18:22, Edzer Pebesma a écrit :
> 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
>

-- 
Renaud Lancelot
EDENext Project, coordinator: http://www.edenext.eu/

CIRAD, UMR15, Campus International de Baillarguet TA A-DIR / B
F34398 Montpellier

Tel.  +33 4 67 59 37 17  -  Fax  +33 4 67 59 37 95
Secr. +33 4 67 59 37 37  - Cell. +33 6 77 52 08 69



More information about the R-sig-Geo mailing list