[R-sig-Geo] spplot with legend only, and legend inside the plotting area

Oscar Perpiñán Lamigueiro oscar.perpinan at upm.es
Wed Mar 7 13:11:53 CET 2012


Mauricio Zambrano-Bigiarini <mauricio.zambrano at jrc.ec.europa.eu> writes:

> I need to produce two different spplot figures of spatial points, and
> I would like to ask your help for the creation of the second one:
>
> 1) the first figure has to show the values but without any legend:
>
> library(sp)
> xyz = data.frame(expand.grid(x=1:10,y=1:10),rnorm(100))
> coordinates(xyz)=~x+y
> spplot(xyz, cex=10, alpha=0.7, auto.key=FALSE)
>
> (I don't have any problem with this)
>
>
> 2) The second figure has to show ONLY the legend for the values of the
> previous figure (without plotting the points), inside the plotting
> area.
>
> I tried with:
>
> spplot(xyz, cex=0, alpha=0.7, auto.key=TRUE, key.space="center")

Hello,

Try this:

spplot(xyz, auto.key=list(x=.5, y=.5), cex=0)

Change the values of x,y for your convenience. You can also find useful
"corner" instead of x,y. For more information read the "auto.key", "key" and
"legend" parts of the help page of xyplot.

Cheers,

Oscar.
-- 
Oscar Perpiñán Lamigueiro
Dpto. Ingeniería Eléctrica
EUITI-UPM

http://procomun.wordpress.com



More information about the R-sig-Geo mailing list