View source: R/geom_text_phylo.R
geom_text_phylo | R Documentation |
This geom adds labels to all or a subset of the nodes of a phylogenetic tree
that has been plotted using ggtree::ggtree()
. It is therefore very similar
to ggtree::geom_tiplab()
, ggtree::geom_tiplab2()
,
ggtree::geom_nodelab()
, and ggtree::geom_nodelab2()
. However, unlike
those geoms, this geom is intended to work with all coordinate systems,
including coord_geo()
and coord_geo_radial()
.
geom_text_phylo(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
node_type = "tip",
auto_adjust = TRUE,
check_overlap = FALSE,
size.unit = "mm",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
parse |
If |
nudge_x , nudge_y |
Horizontal and vertical adjustment to nudge labels by.
Useful for offsetting text from points, particularly on discrete scales.
Cannot be jointly specified with |
node_type |
Determines the subset of nodes to label. Valid options are "tip" for tip nodes, "internal" for non-tip nodes, and "all" for all nodes. |
auto_adjust |
Should upside-down text labels automatically be rotated 180° to improve readability? |
check_overlap |
If |
size.unit |
How the |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Each label will be plotted with the same angle as the branch/edge leading to
its node by default. The angle
, hjust
, and vjust
aesthetics can be used
to adjust this. If custom angle
values are specified, these will be
added to the default angle as calculated as described above.
As with ggplot2::geom_text()
, the limits of axes will not be
expanded to accommodate the new labels, so you may need to extend them
manually using the limits
or expand
arguments within scale_
or coord_
functions. Note that coord_geo()
by default sets expand = FALSE
.
geom_text_phylo()
understands the following
aesthetics (required aesthetics are in bold):
x (pulled from the phylogeny by default)
y (pulled from the phylogeny by default)
label (pulled from the phylogeny by default)
alpha
angle
color/colour
family
fontface
group
hjust
lineheight
size
vjust
You can modify text alignment with the vjust
and hjust
aesthetics. These can either be a number between 0 (right/bottom) and
1 (top/left) or a character ("left"
, "middle"
, "right"
, "bottom"
,
"center"
, "top"
). There are two special alignments: "inward"
and
"outward"
. Inward always aligns text towards the center, and outward
aligns it away from the center.
library(ggplot2)
library(ape)
library(ggtree)
tr <- rtree(10)
revts(ggtree(tr)) +
geom_text_phylo() +
coord_geo_radial("epochs")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.