geom_phylomorpho {deeptime} | R Documentation |
Plot a 2-D phylomorphospace in ggplot2
Description
This behaves similar to phytools::phylomorphospace()
, but is
for plotting a 2-D phylomorphospace with ggplot2::ggplot()
.
This function works like any other ggplot2
geom; it can be
combined with other geoms (see the example below), and the output can be
modified using scales, themes, etc.
Usage
geom_phylomorpho(
tree,
mapping = NULL,
data = NULL,
position = "identity",
...,
seg_args = list(),
point_args = list(),
arrow = NULL,
arrow.fill = NULL,
lineend = "butt",
linejoin = "round",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
tree |
An object of class "phylo". |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to both
|
seg_args |
A list of arguments passed only to
|
point_args |
A list of arguments passed only to
|
arrow |
specification for arrow heads, as created by |
arrow.fill |
fill colour to use for the arrow head (if closed). |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Details
The ancestral states are estimated using phytools::fastAnc()
.
The nodes are connected using ggplot2::geom_segment()
,
while the tips are indicated using ggplot2::geom_point()
.
The default expectation is that the order of the data is the same order as
the tip labels of the tree (tree$tip.label
). However, if this is not
the case, you can map the optional label
aesthetic to a column in the
data that contains the tip names (see example below).
Examples
library(ggplot2)
library(ape)
tr <- rtree(10)
dat <- data.frame(
x = runif(10), y = runif(10), label = tr$tip.label,
row.names = tr$tip.label
)
ggplot(dat, aes(x = x, y = y, label = label)) +
geom_phylomorpho(tr) +
geom_label(size = 5)