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

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, with.missing = "auto", cpal = NULL, missing.color = NULL,
      ltext = NULL, position = "topleft", cex = 1, boxes=TRUE, fontsize, ...)

### Arguments

`seqdata` | a state sequence object (of class `stslist`) as returned by the `seqdef` function.
`with.missing` | logical: 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 `FALSE` omits the legend for the missing state.
`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`).
`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 `seqdef`).
`position` | the position of the legend in the graphic area. For accepted values, see the `x` argument of `legend`. Defaults to `"topleft"`.
`cex` | 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.
`boxes` | logical: should the colors be displayed in small square boxes? Default is `TRUE`. If `FALSE`, colors are shown using small line segments of by default length .4 and width 15. The latter can be changed by means of the `lwd` and `seg.len` `par` arguments.
`fontsize` | Deprecated. Use `cex` instead.
`...` | optional arguments passed to the `legend` function.

### Details

When `x`, `legend`, or `col` arguments are provided, they supersede respectively the `position`, `ltext`, and `cpal` values.

### Value

Coordinate values returned by the `legend` function.

### Author(s)

Alexis Gabadinho and Gilbert Ritschard

### Examples

    ## Loading the 'actcal' example data set
    ## and defining a sequence object with
    ## activity statuses from Jan. to Dec. 2000 (columns 13 to 24)
    ## of first 100 cases.
    data(actcal)
    actcal.seq <- seqdef(actcal[1:100,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, sortv="from.start", with.legend=FALSE)
    seqfplot(actcal.seq, pbarw=TRUE, with.legend=FALSE)
    seqdplot(actcal.seq, with.legend=FALSE)
    seqlegend(actcal.seq)

[Package TraMineR version 2.2-4 Index]