Learn R Programming

TraMineR (version 1.8-9)

seqlegend: Plot a legend for the states in a sequence object

Description

Plots a legend for the states in a sequence object. Useful if several graphics are plotted together and only one legend is necessary. Unless specified by the user, the cpal and labels attributes of the sequence object are used for the colors and text appearing in the legend (see seqdef).

Usage

seqlegend(seqdata, with.missing="auto",
         cpal=NULL, missing.color=NULL, ltext=NULL,
         position="topleft", fontsize=1, ...)

Arguments

seqdata
a sequence object as returned by the the seqdef function.
with.missing
if set to "auto" (default), a legend for the missing state is added automatically if one or more of the sequences in seqdata contains a missing state. If TRUE a legend for the missing state is added in any case. Setting to
cpal
alternative color palette to use for the states. If user specified, a vector of colors with number of elements equal to the number of distinct states. By default, the 'cpal' attribute of the 'seqdata' sequence object is used (see
missing.color
alternative color for representing missing values inside the sequences. By default, this color is taken from the "missing.color" attribute of the sequence object being plotted.
ltext
optional description of the states to appear in the legend. Must be a vector of character strings with number of elements equal to the number of distinct states. If unspecified, the 'labels' attributes of the 'seqdata' sequence object is used (see <
position
the position of the legend in the graphic area. For accepted values, see legend. Defaults to "topleft".
fontsize
size of the font for the labels. A value less than 1 decreases the font size, a value greater than 1 increases the font size. Defaults to 1.
...
optional arguments passed to the legend function.

Examples

Run this code
## Loading the 'actcal' example data set
## and defining a sequence object with
## (activity statuses from jan. to dec. 2000)
## the data in columns 13 to 24
data(actcal)
actcal.seq <- seqdef(actcal,13:24,
	labels=c("> 37 hours", "19-36 hours", "1-18 hours", "no work"))

## Plotting the sequences frequency,
## the states distribution
## and the legend
par(mfrow=c(2,2))
seqiplot(actcal.seq, tlim=0, withlegend=FALSE, border=NA, space=0)
seqfplot(actcal.seq, pbarw=TRUE, withlegend=FALSE)
seqdplot(actcal.seq, withlegend=FALSE)
seqlegend(actcal.seq)

Run the code above in your browser using DataLab