Create an interactive visualisation of a taxonomic hierarchy.
Arguments
- graph
a
taxonomy_graph
object, typically created withread_taxonomy()
.- show
character giving the names of taxa that should be visible. The tree will be shown uncollapsed up to those taxa.
- expand_rank
character giving the names of ranks that should always be expanded.
- full_expand
character giving the names of taxa that should be fully expanded, i.e., all taxa below the given taxon should be visible. Note that this does not expand the graph above the given taxon, such that the expanded part may be invisible. Use
show
to expand the graph up to a given taxon.- focus
character giving one or several taxa to focus on. This means that the tree up to this taxon will be expanded as well as the full subtree below that taxon. It is equivalent to putting the same taxa in
show
andfull_expand
. Iffocus
is used, those other two arguments will be ignored.- highlight
character giving the names of taxa that should be highlighted.
- show_images
should images be shown in tooltips. This requires that image URLs are contained in the
taxonomy_graph
. URLs from Wikipedia can be automatically added usingenrich_taxonomy_with_images()
.- image_size
integer giving the width of images in pixels.
- link_length
length of the horizontal links that connect nodes in pixels.
- font_size
font size of the labels in pixels.
Details
The function makes use of the html widget defined in the package
collapsibleTree
but not of the function
collapsibleTreeNetwork()
from that package that can produce the same plot from the same input data.
plot_taxonomy()
is less flexible than the function from
collapsibleTree but also much faster.
Examples
file <- get_example_taxonomy_file()
taxonomy <- read_taxonomy(file)
plot_taxonomy(taxonomy)
# expand the full path to the grizzly bear
plot_taxonomy(taxonomy, show = "Grizzlybär")
# fully expand the cat family (Felidae)
# The cats are not visible, because the nodes above are not expanded.
plot_taxonomy(taxonomy, full_expand = "Katzen")
# expand the path up to the family of the cats and everything below
plot_taxonomy(taxonomy, focus = "Katzen")
# add images to tooltips
plot_taxonomy(taxonomy, focus = "Bären", show_images = TRUE)
# show and highlight black bear and kodiak bear
plot_taxonomy(taxonomy,
show = c("Amerikanischer Schwarzbär", "Kodiakbär"),
highlight = c("Amerikanischer Schwarzbär", "Kodiakbär"))