Learn R Programming

TraMineR (version 1.6-2)

plot.stslist: 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, tlim=NULL, weighted=TRUE, sortv=NULL,
    cpal=NULL, missing.color=NULL,
    ylab, yaxis=TRUE, xaxis=TRUE, ytlab=NULL, ylas=0, 
    xtlab=NULL, cex.plot=1, ...)

Arguments

x
a state sequence object created with the seqdef function.
tlim
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
if TRUE and weights are assigned to sequences (see seqdef), the width of the bar representing each sequence is proportional to its weight.
sortv
name of an optional variable used to sort the sequences before plotting.
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 states in the alphabet. By default, the cpal attribute of the seqdata sequence object is used (
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.
ylab
An optional label for the y axis. If set to NA, no label is drawn.
yaxis
Controls whether the y axis is plotted or not. When set to TRUE, sequence indexes are displayed.
xaxis
if TRUE (default), the x (time) axis is plotted.
ytlab
the labels of the sequences being plotted to appear on the y axis. Default is the indexes of the sequences as defined by the tlim argument. Can be set to "id" which plots the row names (id) of the sequences instead, as defined by
ylas
sets the orientation of the sequence labels appearing on the y axis. Accepted values are the same as for the standard las option 0: always parallel to the axis (default), 1: always horizontal, 2: always perpendicular to the axis,
xtlab
optional labels for the x axis ticks labels. If unspecified, the column names of the seqdata sequence object are used (see seqdef).
cex.plot
expansion factor for setting the size of the font for the axis labels and names. The default value is 1. Values lesser than 1 will reduce the size of the font, values greater than 1 will increase it.
...
arguments to be passed to the plot function or other graphical parameters.

Details

This is the default plot method for state sequence objects (produced by the seqdef function), i.e. objects of class stslist. It produces a sequence index plot, where individual sequences are rendered with stacked bars depicting the statuses over time. This method is called by the generic seqplot function (if type="i") that produces more sophisticated plots, allowing grouping and automatic display of the states legend. The seqiplot function is a shortcut for calling seqplot with type="i". The interest of sequence index plots has for instance been stressed by Scherer (2001), Brzinsky-Fay et al. (2006) and Gauthier (2007). Notice that such index plots for thousands of sequences result in very heavy graphic files if they are stored in PDF or POSTSCRIPT format. To reduce the size, we suggest saving the figures in bitmap format by using for instance png instead of postscript or pdf.

Examples

Run this code
## 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.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 all data set
## with no borders
plot(biofam.seq, tlim=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)

Run the code above in your browser using DataLab