Skip to contents

Draws the tree as a rectangular phylogram with each branch coloured by its rate. Works with any rate per branch: the truth from trait_rates(), history_rates(), turnover_rates() or food_web_rates(), or estimates such as those of RRphylo, as long as they follow the order of the rows of tree$edge.

Usage

plot_rates(
  tree,
  rates = NULL,
  log = TRUE,
  palette = "viridis",
  tip_labels = FALSE,
  linewidth = 1,
  title = NULL
)

Arguments

tree

A phylo object with branch lengths, or a result of trait_rates(), which carries its tree and rates.

rates

Rate of each branch, in the order of the rows of tree$edge, or a result of trait_rates(), whose edge_rates are used. Left out when tree is a result of trait_rates().

log

Colour by the logarithm of the rate (the default), since rates are multiplicative. Needs positive rates; use FALSE for estimates that can be negative.

palette

Name of a palette of grDevices::hcl.colors().

tip_labels

Draw the names of the tips.

linewidth

Width of the branches.

title

Title of the plot, or NULL.

Value

A ggplot object.

Examples

set.seed(1)
tree <- treeshapesim::sim_tree_shape(30)
x <- trait_rates(tree, "shift", shifts = 2, shift_size = c(8, 1 / 8))
plot_rates(x)

habitat <- trait_mk(tree, q = 0.5, states = c("forest", "open"))
plot_rates(tree, history_rates(habitat, "state", state_rates = c(forest = 1, open = 5)))