phylopic_key_glyph: Use PhyloPics as legend key glyphs

View source: R/geom_phylopic.R

phylopic_key_glyphR Documentation

Use PhyloPics as legend key glyphs

Description

Specify existing images, taxonomic names, or PhyloPic uuids to use PhyloPic silhouettes as legend key glyphs in a ggplot plot.

Usage

phylopic_key_glyph(img = NULL, name = NULL, uuid = NULL)

Arguments

img

A Picture or png array object, e.g., from using get_phylopic().

name

character. A taxonomic name to be passed to get_uuid().

uuid

character. A valid uuid for a PhyloPic silhouette (such as that returned by get_uuid() or pick_phylopic()).

Details

One (and only one) of img, name, or uuid must be specified.

This argument may also be a vector/list of valid values if multiple silhouettes should be used as key glyphs. In this case, the specified silhouettes will be used as ordered as key glyphs one by one, with recycling as necessary.

Note that the sizes of the silhouettes in the legend are currently maximized based on the size of the key. This size can be modified using the legend.key.size argument in ggplot2::theme(). Therefore, the silhouettes will not reflect the size aesthetic, and this function should not be used for size legends.

Examples

## Not run: 
library(ggplot2)
df <- data.frame(x = c(2, 4), y = c(10, 20),
                 name = c("Felis silvestris catus", "Odobenus rosmarus"))
ggplot(df) +
  geom_phylopic(aes(x = x, y = y, name = name, color = name), size = 10,
                show.legend = TRUE,
                key_glyph = phylopic_key_glyph(name =
                                               c("Felis silvestris catus",
                                                 "Odobenus rosmarus"))) +
  coord_cartesian(xlim = c(1,6), ylim = c(5, 30))

## End(Not run)

rphylopic documentation built on Nov. 2, 2023, 6:13 p.m.