
Add PhyloPics to a phylogenetic tree plotted with base R
Source:R/add_phylopic_tree.R
add_phylopic_tree.Rd
Specify existing images, taxonomic names, or PhyloPic uuids to add PhyloPic silhouettes alongside the associated leaves of a phylogenetic tree that has been plotted in the active graphics device using the base R graphics functions.
Arguments
- tree
The phylogenetic tree object of class
phylo
on which to add the silhouette.- tip
The tip labels against which to add the silhouettes. If not specified, the names of the
img
,uuid
orname
vector are used.- img
A Picture or png array object, e.g., from using
get_phylopic()
.- name
character
. A taxonomic name to be passed toget_uuid()
.- uuid
character
. A valid uuid for a PhyloPic silhouette (such as that returned byget_uuid()
orpick_phylopic()
).- width
numeric
. Width of the silhouette in coordinate space. If "NULL", the default, andheight
is also "NULL", the silhouette will be as large as fits in the plot area. If "NULL" andheight
is specified, the width is determined by the aspect ratio of the original image. One or both ofheight
andwidth
must be "NULL".- padding, relPadding
Distance to inset each silhouette from the right edge of the plotting area, in the plot coordinate system (
padding
) or relative to the size of the plotting area (relPadding
). Negative values offset to the right.- relWidth
The width of each silhouette relative to the plotting area.
- hjust
numeric
. A numeric vector between 0 and 1 specifying horizontal justification (left = 0, center = 0.5, right = 1).- ...
Further arguments to pass to
add_phylopic_base()
.
See also
For trees plotted using ggtree, see geom_phylopic()
.
Examples
if (FALSE) { # \dontrun{
# Load the ape library to work with phylogenetic trees
library("ape")
# Read a phylogenetic tree
tree <- ape::read.tree(text = "(cat, (dog, mouse));")
# Set a large right margin to accommodate the silhouettes
par(mar = c(1, 1, 1, 10))
# Plot the tree
plot(tree)
# Add a PhyloPic silhouette of a cat to the tree
add_phylopic_tree(
tree, # Must be the tree that was plotted
"cat", # Which leaf should the silhouette be plotted against?
uuid = "23cd6aa4-9587-4a2e-8e26-de42885004c9", # Silhouette to plot
relWidth = 0.2,
fill = "brown"
)
} # }