Function to generate a simple key

Share:

Description

Simple interface to generate a list appropriate for draw.key

Usage

1
2
3
4
5
6
simpleKey(text, points = TRUE,
          rectangles = FALSE,
          lines = FALSE,
          col, cex, alpha, font,
          fontface, fontfamily, 
          lineheight, ...)

Arguments

text

character or expression vector, to be used as labels for levels of the grouping variable

points

logical

rectangles

logical

lines

logical

col, cex, alpha, font, fontface, fontfamily, lineheight

Used as top-level components of the list produced, to be used for the text labels. Defaults to the values in trellis.par.get("add.text")

...

further arguments added to the list, eventually passed to draw.key

Details

A lattice plot can include a legend (key) if an appropriate list is specified as the key argument to a high level Lattice function such as xyplot. This key can be very flexible, but that flexibility comes at a cost: this list needs to be fairly complicated even in simple situations. simpleKey is designed as a useful shortcut in the common case of a key drawn in conjunction with a grouping variable, using the default graphical settings.

The simpleKey function produces a suitable key argument using a simpler interface. The resulting list will use the text argument as a text component, along with at most one set each of points, rectangles, and lines. The number of entries (rows) in the key will be the length of the text component. The graphical parameters for the additional components will be derived from the default graphical settings (wherein lies the simplification, as otherwise these would have to be provided explicitly).

Calling simpleKey directly is usually unnecessary. It is most commonly invoked (during the plotting of the "trellis" object) when the auto.key argument is supplied in a high-level plot with a groups argument. In that case, the text argument of simpleKey defaults to levels(groups), and the defaults for the other arguments depend on the relevant high-level function. Note that these defaults can be overridden by supplying auto.key as a list containing the replacement values.

Value

A list that would work as the key argument to xyplot, etc.

Author(s)

Deepayan Sarkar Deepayan.Sarkar@R-project.org

See Also

Lattice, draw.key, trellis.par.get, and xyplot, specifically the entry for auto.key.

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.