Plot objects in a list

Share:

Description

Plot all objects given in a list, with parameters that can be given as a named list.

Usage

1
2
  lplot(objects = NULL, ..., allinone = TRUE,
    .plotmethod = "plot")

Arguments

objects

named list of R-objects.

...

parameters and parameterlists passed to plot method of the objects.

allinone

logical, if TRUE, all objects are plotted in one window.

.plotmethod

a generic function for plotting, or a character string naming a generic function. Defaults to "plot" and should usually not be changed. #'

Details

Only objects that belong to classes with a plot method are plotted. The plot parameters may be given as lists with the same name as the objects list. Parameters in named lists are assigned to the object with same name in list objects. Plot parameters not given in a list apply to all objects. Plot parameters may also be grouped as style lists, since lplot internally calles splot.

Any add-parameters only affect the first plotted object. Whether or not the plots of the remaining objects are added to the first plot, is controlled by parameter allinone.

Author(s)

Ute Hahn, ute@imf.au.dk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# a list of plottable objects: functions
curves <- list(b = cos, a = sin)
lplot(curves, col = list(a = "green", b = "red"), ylim = c(-1, 1), to = pi)
# start a new plot for every object
lplot(curves, allinone = FALSE, col = list(a = "green", b = "red"),
     ylim = c(-1, 1), to = pi)

# using plot styles
curves <- list(b = cos, a = sin)
mystyles <- list(a = style(col = "red", lwd = 2), b = style(col = "green"))
lplot(curves, mystyles, ylim = c(-1, 1), to = 2*pi)