Illustrates individual categorical trajectories in a modified timeseries plot. The x scale represents the order position (often the timestamp), the y the response category (events or state).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  ctplot(x,y,id,weights=NULL,
cov=NULL,subset=NULL,type="distinctive",
embedding="mostfrequent",x.order=FALSE,
x.orderalign=ifelse(split=="last","last","first"),
y.optimalphabet=FALSE,R=NULL,
main="",sub=NULL,mtext=TRUE,
xlab="order position",ylab="",xlim=NULL,ylim=NULL,
grid.col="white",grid.fill="grey90",
grid.scale=1/4,grid.shape="default",grid.lwd=0,
cpal=NULL,alpha=1,lcourse="upwards",lorder="background",
lweights=TRUE,lwd.min=0.5,lwd.max=2,lty=1,pch=4,
cex=1,border=grid.col,border.lwd=grid.lwd/2,
sf.cex=1,sf.cex.leaves=1,sf.pch=16,rotate=FALSE,
split=NULL,layout=NULL,
show.type=1,show=c(0,1),hide.col="grey75",
hide.s=0.1,hide.na.cost=1,
print=FALSE,return.data=FALSE,...)

x 
The order position vector. 
y 
The response vector (i.e events, ordinal responses etc.). 
id 
The subject identification vector. Either a factor or an integer vector. 
weights 
A weights vector that corresponds to the subjects defined by the id vector. If id is a factor, the length of weights must be equal to the number of levels of the id vector. The first value of weights is the assigned to the first id label etc.. If id is an integer vector, the length of weights must be equal to the number of distinctive numbers in id. 
cov 
A grouping vector which splits the plot into one panel per group. This vector must be defined analogous as the "weights" vector. 
subset 
An optional vector of id labels which should be omitted. 
type 
The type of trajectories to draw. Either "distinctive" or "nonembeddable". 
embedding 
Option for type="nonembeddable", the method how to assign trajectories having multiple corresponding nonembeddable trajectories. Either "mostfrequent" (default) or "uniformly". 
x.order 
Logical. Transforms the x vector into individual integer orders 
x.orderalign 
Alignment mode for data where the order positions are individual integer orders. align="first" aligns the trajectories left hand, align="last" right hand. Assigning an y category produces an alinement of the first occurrences of this category. 
y.optimalphabet 
Logical. Indicates if arrangements of y categories should be optimized. Works only with a limited number of categories. 
R 
Accelerate the y order optimisation procedure. Set a number in case of y provides many categories. 
main 
A main title for the plot, see also "title". 
sub 
Subtitles. Used in case of multiple plot panels. 
mtext 
Logical. Print panel information or not. 
xlab 
A label for the x axis, defaults to a description of "x". 
ylab 
A label for the y axis, defaults to a description of "y". 
xlim 
The x limits (x1, x2) of the plot. 
ylim 
The y limits (y1, y2) of the plot. 
grid.col 
Color of border of underlaid rectangles. 
grid.fill 
Color of underlaid rectangles. 
grid.scale 
Expansion degree of underlaid rectangles. 
grid.shape 
Either "default" or "proportional". 
grid.lwd 
Line width or border of underlaid rectangles. 
cpal 
A colour palette to be assigned to the sequences. 
alpha 
Degree of line and symbol transparency. Choose a number between 0 and 1. 
lorder 
Either "background" (default) or "foreground". The first plots infrequent trajectories, the latter the frequent trajectories in the front. 
lcourse 
Handling for line connection of simultaneous observations. Either "upwards" or "downwards". 
lweights 
logical: Should the line width be
proportional to the represented trajectory? If 
lwd.min 
The minimal line width to be drawn in the plot. 
lwd.max 
The maximal line width to be drawn in the plot. 
lty 
Line type of lines connecting succeeding observations. 
pch 
"pch" the plotting symbols: see 
cex 
Expansion factor for the plotted squared symbols. 
border 
Color of symbol borders. 
border.lwd 
Line widths of symbol borders 
sf.cex 
Expansion factor of the center points of plotted sunflowers. 
sf.cex.leaves 
Expansion factor for leaves the of plotted sunflowers. 
sf.pch 
Plotting character to be used for points
( 
rotate 
Logical. If 
split 
Logical value for plot panel arrangement modes. If

layout 
Integer vector of length 2. Determines the number of rows and columns of the plot panels arrangement. 
show.type 
Criteria which trajectories to set in the
foreground. Type 1 (default) shows trajectories which present relative
frequencies between the two values assigned to the " 
show 
Vector of two values between 0 and 1. Indicate the minimal and maximal relative frequency for a trajectory to be presented in the foreground of the plot. 
hide.col 
color of trimmed trajectories. If set to "white" trajectories are not shown at all. 
hide.s 
Option for ordinal sequences. Experimental. 
hide.na.cost 
Option of for ordinal sequences. Experimental. 
print 
Prints the current step of the plot procedure. 
return.data 
Returns the plot data in a list. 
... 
Arguments to be passed to methods, such as graphical
parameters (see 
Coming soon.
Bürgin, R., G. Ritschard and E. Rousseaux (2012), "Exploration graphique de données séquentielles". In Atelier Fouille Visuelle de Données : méthologie et évaluation, EGC 2012, Bordeaux. Association EGC: http://www.egc.asso.fr/sdoc237egc2012_atelier_fvd.pdf .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58  ## ==================
## the plot principle
## ==================
x < c(1,2,2,2,3,4,1,2,2,2,3,4,1,1.5,2,2,3,3.5,4,4,1,2,2,2,3,4,
1,2,3,4,3.5,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,1,2,
1,2,3,4,1,2)
y < factor(c("A","B","B","B","C","A","A","B","B","B","C","A","A",
"B","B","C","C","C","C","C","A","B","B","B","C","A",
"A","A","A","A","A","B","A","A","A","A","A","A","A",
"A","A","A","A","A","A","A","A","A","A","A","A","A",
"A","A","A","A","A","B","C","A","A","A"))
id < factor(c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,
5,5,5,5,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,
11,11,11,11,12,12,13,13,14,14,14,14,15,15))
ctplot(x,y,id,lwd.min=5,lwd.max=12,cex=1,
type="nonembeddable",alpha=0.9,
sf.cex=0.5,sf.cex.leaves=1,grid.scale=0.4)
## ====================
## plot the biofam data
## ====================
## loading the data and defining an event sequence dataset
## =======================================================
data(biofam)
lab < c("Parent","Left","Married",
"Left+Marr","Child","Left+Child",
"Left+Marr+Child","Divorced")
biofam.seq < seqdef(data=biofam,var=10:25,labels=lab)
biofam.TSE < seqformat(data=biofam.seq,from="STS",to="TSE",
tevent=seqetm(seq=biofam.seq,method="state"))
biofam.TSE$event < factor(biofam.TSE$event,levels=lab)
## plot the data
## =============
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,
y=biofam.TSE$event,
id=biofam.TSE$id,x.order=TRUE,
type="nonembeddable",lwd.max=10)
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,y=biofam.TSE$event,
id=biofam.TSE$id,split="first",layout=c(2,1),
grid.scale=0.5,x.order=TRUE)
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,y=biofam.TSE$event,
id=biofam.TSE$id,
x.order=TRUE,x.orderalign="last",split="last",
layout=c(4,2),lwd.max=2.5,grid.scale=0.5)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.