seqlegend {TraMineR} | R Documentation |
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, cpal, ltext,
position="topleft", fontsize=1)
Arguments
seqdata |
a sequence object as returned by the the seqdef function. |
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 seqdef ). |
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 seqdef ). |
position |
the position of the legend in the graphic area. For accepted values, see legend . Default 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. Default to 1. |
Examples
## 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)
[Package
TraMineR version 1.1
Index]