plot.phyloLayout: plot.phyloLayout

View source: R/tree.R

plot.phyloLayoutR Documentation

plot.phyloLayout

Description

Generic plot function for phylogenetic trees with layouts generated using ggfree. The coordinate system of the plot depends on the layout algorithm:

Rectangular/slanted layout: The x-axis is scaled to the height of the tree (from the root to the furthest tip). The y-axis is scaled to the number of tips (1:Ntip(phy)).

Circular (radial) layout: Graphical parameters such as 'col' or 'lwd' can take either a single value or a vector to specify custom values for each edge. The ordering should be the same as the original tree (phylo) object, which defaults to preorder traversal.

Usage

## S3 method for class 'phyloLayout'
plot(
  obj,
  type = "l",
  col = "grey50",
  lwd = 2,
  label = "t",
  cex.lab = 0.8,
  mar = NA,
  xlim = NA,
  add = FALSE,
  offset = 0,
  ...
)

Arguments

obj:

S3 object of class 'phyloLayout'

type:

if 'n', then line segments are not drawn

col:

colour for line segments. Defaults to 'grey50'.

lwd:

stroke width for line segments. Defaults to 2.

label:

Specifies whether nodes are labeled with text.

  • 'n'No node labels.

  • 't'Tip labels only (default).

  • 'i'Internal node labels only.

  • 'b'Both tip and internal node labels.

cex.lab:

Character expansion factor for node labels (default 0.8).

mar:

(optional) vector of margin widths (graphical parameter).

...:

additional graphical parameters to pass to 'lines' and 'label'

Examples

# generate random coalescent tree
set.seed(1999); phy <- rcoal(50)

# rectangular tree
plot(tree.layout(phy, type='r'), mar=c(3,0,0,1))
axis(side=1)

# unscaled slanted tree with colors
pal <- colorRampPalette(c('cadetblue', 'brown'))
plot(tree.layout(phy, type='s', unscaled=TRUE), col=pal(5))

# unrooted tree
plot(tree.layout(phy, type='u'))

# circular (radial) tree
plot(tree.layout(phy, type='o'), label='t')


ArtPoon/ggfree documentation built on July 11, 2024, 11:15 a.m.