getLatticeLegend: Get the nodes corresponding to the legend in a lattice plot

Description Usage Arguments Value Author(s) See Also Examples

Description

This function uses heuristics to find the SVG nodes corresponding to the legend generated via the auto.key parameter in a lattice plot. One can then use this to annotate the SVG, e.g. put links or mouseover handlers on the labels.

Usage

1
getLatticeLegendNodes(doc, plotRegions = getPlotRegionNodes(doc), which = NA)

Arguments

doc

the parsed SVG document, i.e. an object of class XMLInternalDocumet

plotRegions

typically not specified, but this allows the caller to identify the plot region nodes.

which

if specified, an integer identifying which legend is of interest. This is for the case where there is more than one legend/key in the plot, i.e. via the legend argument.

Value

A list of XMLInternalNode objects.

Author(s)

Duncan Temple Lang

See Also

svgPlot xmlParse the lattice package.

Examples

1
2
3
4
5
6
7
 library(lattice)
 d = data.frame(x = runif(100), y = runif(100),
                type = sample(c("A", "B", "C"), 100, replace = TRUE),
                g = sample(c("w", "x", "y", "z"), 100, replace = TRUE))
 doc = svgPlot(xyplot(y ~ x | type, d, groups = g, auto.key = TRUE))
 nodes = getLatticeLegendNodes(doc)
 length(nodes)

duncantl/SVGAnnotation documentation built on May 15, 2019, 5:57 p.m.