# plot-PSTr: Plot a PST In PST: Probabilistic Suffix Trees and Variable Length Markov Chains

Plot a PST

## Usage

 ```1 2 3 4 5 6 7``` ``` ## S4 method for signature 'PSTf,ANY' plot(x, y=missing, max.level=NULL, nodePar = list(), edgePar = list(), axis=FALSE, xlab = NA, ylab = if (axis) { "L" } else {NA}, horiz = FALSE, xlim, ylim, withlegend=TRUE, ltext=NULL, cex.legend=1, use.layout=withlegend!=FALSE, legend.prop=NA, ...) ```

## Arguments

 `x` A PST, that is an object of class `PSTf` as returned by the `pstree` or `prune` method. `y` not applicable `max.level` integer. The maximal depth for the display of the tree. `nodePar` list. A list of parameters for tuning the node representation. Possible parameters are node.size. numeric. The size of the node, in fraction of a unit of the x axis (or y axis if horiz=TRUE). gratio. The ratio between horizontal and vertical dimensions of the node. usefull if the horizontal and vertical dimensions of the plot are not equal. If not provided, it is estimated as a function of the number of leaves represented in the plot and the depth of the tree. `edgePar` list. A list of parameters for tuning the edges representation. Possible paramters are `axis` logical. If TRUE the axes are displayed on the plot. `xlab` character. Label for the x axis. `ylab` character. Label for the y axis representing the tree depth. `horiz` logical. If FALSE, the tree is represented vertically. The root node at depth L=0 is plotted on the top, and the nodes of maximal depth are plotted on the bottom of the plot. If TRUE, the tree is represented horizontally. The root node at depth L=0 is plotted on the right, and the nodes of maximal depth are plotted on the left of the plot. `xlim` numeric. Vector of length 2 giving the x limits for the plot. By default the limits are 1 .. number of terminal nodes (at max.level if specified). This may be usefull to facilitate comparison if several trees are plotted on the same figure. `ylim` numeric. Vector of length 2 giving the y limits for the plot. By default the limits are 0 .. max. depth of the tree (max.level if specified). This may be usefull to facilitate comparison if several trees are plotted on the same figure. `withlegend` defines if and where the legend of the state colors is plotted. The default value `TRUE` sets the position of the legend automatically. Other possible value is `"right"`. `ltext` optional description of the states to appear in the legend. Must be a vector of character strings with number of elements equal to the size of the alphabet. If unspecified, the `label` attribute of the `seqdata` sequence object is used (see `seqdef`). `cex.legend` expansion factor for setting the size of the font for the labels in the legend. The default value is 1. Values lesser than 1 will reduce the size of the font, values greater than 1 will increase the size. `use.layout` if `TRUE`, `layout` is used to arrange plots when using the group option or plotting a legend. When layout is activated, the standard '`par(mfrow=....)`' for arranging plots does not work. With `withlegend=FALSE` and `group=NULL`, layout is automatically deactivated and '`par(mfrow=....)`' can be used. `legend.prop` sets the proportion of the graphic area used for plotting the legend when `use.layout=TRUE` and `withlegend=TRUE`. Default value is set according to the place (bottom or right of the graphic area) where the legend is plotted. Values from 0 to 1. `...` arguments to be passed to the plot function or graphical parameters

## Details

The function for graphical representation of a PST uses is recursive. The main argument of the function is a tree represented as a nested list (an object of class `PSTr`). See also Gabadinho 2016.

## Author(s)

Alexis Gabadinho, based on code from `plot.dendrogram`

## References

Gabadinho, A. & Ritschard, G. (2016). Analyzing State Sequences with Probabilistic Suffix Trees: The PST R Package. Journal of Statistical Software, 72(3), pp. 1-39.

## Examples

 ```1 2 3 4 5 6 7``` ```data(s1) s1 <- seqdef(s1) S1 <- pstree(s1, L=3) plot(S1) plot(S1, horiz=TRUE) plot(S1, nodePar=list(node.type="path", lab.type="prob", lab.pos=1, lab.offset=2, lab.cex=0.7), edgePar=list(type="triangle"), withlegend=FALSE) ```

### Example output

```Loading required package: TraMineR

TraMineR stable version 2.0-7 (Built: "Sat,)
Website: http://traminer.unige.ch
Please type 'citation("TraMineR")' for citation information.

PST version 0.94 (Built: 2017-09-22)
Website: http://r-forge.r-project.org/projects/pst
[>] 2 distinct states appear in the data:
1 = a
2 = b
[>] state coding:
[alphabet]  [label]  [long label]
1  a           a        a
2  b           b        b
[>] 1 sequences in the data set
[>] min/max sequence length: 27/27
[>] 1 sequence(s) - min/max length: 27/27
[>] max. depth L=3, nmin=1
[L]  [nodes]
0        1
1        2
2        4
3        8
[>] computing sequence(s) likelihood ... (0.01 secs)
[>] total time: 0.291 secs
[>] building 'PSTr' representation, max. depth=3... (0.014 secs)
There were 15 warnings (use warnings() to see them)
[>] building 'PSTr' representation, max. depth=3... (0.003 secs)
There were 15 warnings (use warnings() to see them)
[>] building 'PSTr' representation, max. depth=3... (0.001 secs)
```

PST documentation built on May 29, 2017, 5:16 p.m.