[R] Add title to color spectrum legend in xyplot

Nick Ackerman nick.ackerman at pgn.com
Mon Mar 22 23:58:00 CET 2010


Hi,

I have a plot that is essentially the same as that in Figure 5.6 of "Lattice
- Multivariate Data Visualization with R". The key difference is that I
would like to add a title to top of the grey color spectrum legend, but have
thus far been unsuccessful. I've tried a variety of options, but to no
avail. I'm new to R, and admittedly I don't understand the "legend" argument
that well, and in this case how it interacts with the "key" argument. Thanks
in advance for any help. For reference, here is the code to Figure 5.6. 

xyplot(lat ~ long | Magnitude, data = quakes.ordered, 
       aspect = "iso", groups = color, cex = 2, col = "black",
       panel = function(x, y, groups, ..., subscripts) {
           fill <- groups[subscripts]
           panel.grid(h = -1, v = -1)
           panel.xyplot(x, y, pch = 21, fill = fill, ...)
       },
       legend = 
       list(right = 
            list(fun = draw.colorkey,
                 args = list(key = list(col = gray.colors,
                                        at = depth.breaks), 
                             draw = FALSE))),
       xlab = "Longitude", ylab = "Latitude")

-- 
View this message in context: http://n4.nabble.com/Add-title-to-color-spectrum-legend-in-xyplot-tp1678456p1678456.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list