plot.stslist.rep: Plot method for representative sequence sets

View source: R/plot.stslist.rep.R

plot.stslist.repR Documentation

Plot method for representative sequence sets

Description

This is the plot method for output produced by the seqrep function, i.e, for objects of class stslist.rep. It produces a representative sequence plot.

Usage

## S3 method for class 'stslist.rep'
plot(x, cpal = NULL, missing.color = NULL, pbarw = TRUE,
  dmax = NULL, stats = TRUE, ylab = NULL, xaxis = TRUE, xtlab = NULL,
  xtstep = NULL, tick.last = NULL, seq.alt = NULL, info = TRUE,
  cex.with.axis = 1, cex.plot, ...)

Arguments

x

an object of class stslist.rep as produced by the seqrep 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 states in the alphabet. By default, the 'cpal' attribute of the x 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.

pbarw

when TRUE, the bar heights are set proportional to the number of represented sequences.

dmax

maximal theoretical distance, used for the x axis limits.

stats

if TRUE (default), mean discrepancy in each subset defined by all sequences attributed to one representative sequence and the mean distance to this representative sequence are displayed.

ylab

an optional label for the y axis. If set to NA, no label is drawn.

xaxis

controls whether a x axis is plotted.

xtlab

optional labels for the x axis ticks labels. If unspecified, the column names of the object being plotted.

xtstep

optional interval at which the 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.

seq.alt

an object of class stslist with same number of sequences than the sequence object for which the representatives x are provided. When not NULL, representatives are plotted in this alternative domain.

info

Logical. Should coverage info be displayed? Default is TRUE.

cex.with.axis

Text and symbols magnification.

cex.plot

Deprecated. Use cex.with.axis instead.

...

further graphical parameters such as las to control orientation of tick labels (see par) and barplot arguments such as border=NA to remove the borders of the bars.

Details

This is the plot method for the output produced by the seqrep function, i.e. objects of class stslist.rep. It produces a plot where the representative sequences are displayed as horizontal bars with width proportional to the number of sequences assigned to them. Sequences are plotted bottom-up according to their representativeness score.
Above the plot, two parallel series of symbols associated to each representative are displayed horizontally on a scale ranging from 0 to the maximal theoretical distance D_{max}. The location of the symbol associated to the representative r_i indicates on axis A the (pseudo) variance (V_i) within the subset of sequences assigned to r_i and on the axis B the mean distance MD_i to the representative.

This method is called by the generic seqplot function (if type="r") that produces more sophisticated plots with group splits and automatic display of the color legend. The seqrplot function is a shortcut for calling seqplot with type="r".

Author(s)

Alexis Gabadinho and Gilbert Ritschard

Examples

## Loading the mvad data set and creating a sequence object
data(mvad)
mvad.labels <- c("employment", "further education", "higher education",
                    "joblessness", "school", "training")
mvad.scodes <- c("EM","FE","HE","JL","SC","TR")

## First 36 months trajectories
mvad.seq <- seqdef(mvad, 15:50, states=mvad.scodes, labels=mvad.labels)

## Computing Hamming distances
##
dist.ham <- seqdist(mvad.seq, method="HAM")

## Extracting a representative set using the sequence frequency
## as a representativeness criterion
mvad.rep <- seqrep(mvad.seq, diss=dist.ham)

## Plotting the representative set
plot(mvad.rep)

TraMineR documentation built on May 29, 2024, 5 a.m.