plot.stslist | R Documentation |
This is the plot method for state sequence objects of class stslist
created by the seqdef
function. It produces a sequence index plot.
## 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, ...)
x |
A state sequence object created with the |
idxs |
Indexes of the sequences to be plotted (default value is |
weighted |
Logical: Should the bar representing each sequence be proportional to its weight? Ignored when no weights are assigned to sequences (see |
sortv |
A sorting variable or a sort method (one of |
cpal |
Color palette for the states. A vector of colors of length equal to the number of states in the alphabet. If |
missing.color |
Color for representing missing values inside the sequences. If |
ylab |
String. Optional label of the y-axis. If set to |
yaxis |
Logical. Should the y-axis be plotted. When set as |
xaxis |
Logical. Should the x-axis (time) be plotted? Default is |
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 |
las |
numeric in {0,1,2,3}; the orientation of tick labels.
|
xtlab |
optional labels for the x-axis tick labels. If unspecified, the column names of the |
xtstep |
optional interval at which tick marks and labels of the x-axis are displayed. For example, with |
tick.last |
Logical. Should a tick mark be enforced at the last position on the x-axis? If unspecified, the |
cex.axis |
Axis annotation magnification. See |
tlim |
Deprecated. Use |
cex.plot |
Deprecated. Use |
ylas |
Deprecated. Use |
... |
further graphical parameters (see |
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
.
Gilbert Ritschard
seqplot
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.