Hi All,

I have a question about producing keys in ssplot(). I've included reproducible code below. Here goes:

I'd like to produce a key in ssplot that has both rectangles, points and lines. Unfortunately, when you include all of these symbols in one key, the produce a "staggered" look with rectangles on the far left and lines closest to the labels (run script below to see what I am talking about).

Questions:
1. How can you have them all line up in a single column?
I tried using negative values for "size" of rectangles, but that begins to change the size of the grey background box.

2. key.space does not seem to change anything when used inside the update function. Any suggestions on how to move the key?

Thanks!
-Ken

# Reproducible Script:
library(sp)
library(lattice) # required for trellis.par.set():
trellis.par.set(sp.theme()) # sets color ramp to bpy.colors()

data(meuse)
coordinates(meuse)=~x+y
data(meuse.riv)
meuse.sr = SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv")))

# Create spplot
plot1 = spplot(meuse, "zinc", auto.key=F, panel = function(x, y, ...) {
                sp.polygons(meuse.sr, fill = "lightblue")
                panel.pointsplot(x, y, auto.key = F, ...)
        },
        main = "Top soil zinc concentration (ppm)"
        )
#Update spplot
plot.update <- update(plot1,
key = list(rep = F,  between.row = 0.75, between = 0.8, background="grey90",
key.space = list(x = 0.1, y = 0.93, corner = c(1,0)),
rectangle = list(col = c(rep(NA, 3), rep("magenta", 4)),
                 border = c(rep(NA, 3),rep("black", 4)),
                 size = 1.8, lwd = 7),
points = list(pch = c(NA, seq(1, 2,1), rep(NA, 4)),
              col = c(NA, rep("black", 2), rep(NA, 4))),
lines = list(type = "l", size = 2, lwd = 2, lty = 1),
text = list(rep("Some Variable", 7))
))
#Print spplot
print(plot.update)

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to