plot.stslist {TraMineR}R Documentation

Plot method for state sequence objects

Description

This is the plot method for state sequence objects of class stslist created by the seqdef function. It produces a sequence index plot.

Usage

## S3 method for class 'stslist'
plot(x, idxs = NULL, weighted = TRUE, sortv = NULL,
  cpal = NULL, missing.color = NULL, ylab = NULL,
  yaxis = TRUE, xaxis = TRUE, ytlab = NULL, las = par("las"),
  xtlab = NULL, xtstep = NULL, tick.last = NULL, cex.axis = par("cex.axis"),
  tlim, cex.plot, ylas, ...)

Arguments

x

A state sequence object created with the seqdef function.

idxs

Indexes of the sequences to be plotted (default value is 1:10), for instance 20:50 to plot sequences 20 to 50, c(2,8,12,25) to plot sequences 2,8,12 and 25 in seqdata. If set to 0, all sequences in seqdata are plotted.

weighted

Logical: Should the bar representing each sequence be proportional to its weight? Ignored when no weights are assigned to sequences (see seqdef.)

sortv

A sorting variable or a sort method (one of "from.start" or "from.end"). See details.

cpal

Color palette for the states. A vector of colors of length equal to the number of states in the alphabet. If NULL (default), the cpal attribute of the seqdata sequence object is used (see seqdef).

missing.color

Color for representing missing values inside the sequences. If NULL (default) the color is taken from the "missing.color" attribute of the x sequence object.

ylab

String. Optional label of the y-axis. If set to NA, no label is drawn.

yaxis

Logical. Should the y-axis be plotted. When set as TRUE, sequence indexes are displayed.

xaxis

Logical. Should the x-axis (time) be plotted? Default is TRUE.

ytlab

Character string or vector of length equal to the number of sequences. Labels of the plotted sequences to be used as tick labels on the y-axis. Default is the indexes of the sequences as defined by the idxs argument. Can be set to "id" for displaying the row names (id) of the sequences instead of their indexes; row names can be assigned to the sequence object with the id argument of the seqdef function or afterwards with rownames. Otherwise ytlab can be set to a vector of length equal to the number of sequences to be plotted.

las

numeric in {0,1,2,3}; the orientation of tick labels.
0: always parallel to the axis (default),
1: always horizontal,
2: always perpendicular to the axis,
3: always vertical.

xtlab

optional labels for the x-axis tick labels. If unspecified, the column names of the seqdata sequence object are used (see seqdef).

xtstep

optional interval at which tick marks and labels of the x-axis are displayed. For example, with xtstep=3 a tick mark is drawn at position 1, 4, 7, etc... The display of the corresponding labels depends on the available space and is dealt with automatically. If unspecified, the xtstep attribute of the x object is used.

tick.last

Logical. Should a tick mark be enforced at the last position on the x-axis? If unspecified, the tick.last attribute of the x object is used.

cex.axis

Axis annotation magnification. See par.

tlim

Deprecated. Use idxs instead.

cex.plot

Deprecated. Use cex.axis instead.

ylas

Deprecated. Use las instead.

...

further graphical parameters (see par) and barplot arguments.

Details

This is the default plot method for state sequence objects (produced by the seqdef function), i.e., for objects of class stslist. It produces a sequence index plot, where individual sequences are rendered with stacked bars depicting the successive states in each of the sequences.

This method is invoked by several advanced plot functions such as seqiplot and seqIplot (seqplot with type="i" or "I"), which, in addition to index plots, automatically display the state color legend and allow plotting by group.

When a sortv variable is provided, the sequences are sorted bottom-up according to its values. With sortv = "from.start", sequence are sorted by the elements of the alphabet at the successive positions starting from the beginning of the sequences. Method "from.end" proceeds similarly, but backward from the last position.

Index plots of thousands of sequences result in very heavy graphic files when stored in vectorial (PDF or POSTSCRIPT) format because each sequence, even if hidden, is drawn individually. To reduce the file size, we suggest saving the figures in bitmap format by using for instance png instead of postscript or pdf.

Author(s)

Gilbert Ritschard

See Also

seqplot

Examples

## Defining a sequence object with the data in columns 10 to 25
## (family status from age 15 to 30) in the biofam data set
data(biofam)
biofam <- biofam[500:600,] ## using a subsample only
biofam.lab <- c("Parent", "Left", "Married", "Left+Marr",
    "Child", "Left+Child", "Left+Marr+Child", "Divorced")
biofam.seq <- seqdef(biofam, 10:25, labels=biofam.lab)

## Plot of the 10 most frequent sequences
## with bar width proportional to the frequency
plot(biofam.seq)

## Plotting the whole data set
## with no borders
plot(biofam.seq, idxs=0, space=0, border=NA)

## =======
## Weights
## =======
data(ex1)
ex1.seq <- seqdef(ex1, 1:13, weights=ex1$weights)
plot(ex1.seq)
plot(ex1.seq, weighted=FALSE)

[Package TraMineR version 2.2-10 Index]