[R] Lattice legend

Julio Rojas jcredberry at ymail.com
Tue Jun 14 16:07:27 CEST 2011


Dear all, I have been working in a plot based on figure 5.6 of the Lattice book (http://lmdvr.r-forge.r-project.org/figures/figures.html).

I have already modified it to include the size of the circles as another variable, but I would like to modify the legend to show it (like they do it in http://www.jstatsoft.org/v15/i05/paper). I have divided my variable in intervals:

DATA$s_Shape_2 <- cut(x=DATA$Shape_inde,breaks=c(0.9999999,1.2,1.4,1.7,2.1,5))


I will use the index of the categories as the radius of the circles. Now, following the aforementioned figure 5.6, I have the following code:

NDVI.breaks <- do.breaks(range(DATA.ord$NDVI), 50)

xyplot(Y_Center_P~X_Center_P|Level,data=DATA.ord,col = "black",aspect = "iso",
                                    fill.color = DATA.ord$c_RNDVI, cex = DATA$s_Shape_2,
                                    panel = function(x, y, fill.color, cex,..., subscripts) {
                                            fill <- fill.color[subscripts]
                                            cex <- cex[subscripts]
                                            panel.grid(h = -1, v = -1)
                                            panel.xyplot(x, y, pch = 21, fill = fill, cex = cex,...)
                                            },
                                    legend =
                                    list(right = list(fun = draw.colorkey, args = list(key = list(col = rainbow,
                                         at = NDVI.breaks), draw = FALSE)))
)


How can I add the categories with circles of their respective sizes to the legend?

I hope this is enough information to have some help. If not, let me know.

Regards.

Julio.




More information about the R-help mailing list