Learn R Programming

⚠️There's a newer version (1.6.0) of this package.Take me there.

rphylopic

The idea here is to create modular bits and pieces to allow you to add silhouettes to not only ggplot2 plots, but base plots as well. Some people prefer base plots while others prefer ggplot2 plots (me!), so it would be nice to have both options.

Install

install.packages("remotes")
remotes::install_github("sckott/rphylopic")
library('rphylopic')

Work with names

Get info on a name

id <- "1ee65cf3-53db-4a52-9960-a9f7093d845d"
name_get(uuid = id)
#> $uid
#> [1] "1ee65cf3-53db-4a52-9960-a9f7093d845d"
name_get(uuid = id, options = c('citationStart', 'html'))
#> $html
#> [1] "<span class=\"nomen\"><span class=\"scientific\">Homo sapiens</span> <span class=\"citation\">Linnaeus, 1758</span></span>"
#> 
#> $citationStart
#> [1] 13
#> 
#> $uid
#> [1] "1ee65cf3-53db-4a52-9960-a9f7093d845d"

Searches for images for a taxonomic name.

name_images(uuid = "1ee65cf3-53db-4a52-9960-a9f7093d845d")
#> $other
#> list()
#> 
#> $supertaxa
#> list()
#> 
#> $subtaxa
#> list()
#> 
#> $same
#> $same[[1]]
#> $same[[1]]$uid
#> [1] "c089caae-43ef-4e4e-bf26-973dd4cb65c5"
#> 
#> 
#> $same[[2]]
#> $same[[2]]$uid
#> [1] "ad736445-7147-46f0-9932-d69243dea8f0"
#> 
#> 
#> $same[[3]]
#> $same[[3]]$uid
#> [1] "a146bf1b-c94d-46e1-9cd8-a0ac52a1e0a9"

Find the minimal common supertaxa for a list of names.

name_minsuptaxa(uuid=c("1ee65cf3-53db-4a52-9960-a9f7093d845d", "08141cfc-ef1f-4d0e-a061-b1347f5297a0"))
#> [[1]]
#> [[1]]$canonicalName
#> [[1]]$canonicalName$uid
#> [1] "b44e3b2e-3f21-4583-a760-59ec9d9f04d7"

Find the taxa whose names match a piece of text.

name_search(text = "Homo sapiens", options = "namebankID")[[1]]
#>                                     uid namebankID
#> 1  1ee65cf3-53db-4a52-9960-a9f7093d845d     109086
#> 2  105d17a4-9706-4fd5-85d7-becffaf6250a       <NA>
#> 3  f4067586-1dca-4f21-b91f-530b14958c6b       <NA>
#> 4  b995ecbf-ee0a-4896-a4da-ad1287389c70       <NA>
#> 5  9fee81c4-1a7d-44e6-999f-f2442b99a9db       <NA>
#> 6  47fd19a7-8d1c-417d-b913-8f53a96d03d5       <NA>
#> 7  c1331888-cdc5-42da-904a-b3e33d39e42c       <NA>
#> 8  48236998-7157-4c13-b1b9-1d21fc7c65a6       <NA>
#> 9  15444b9c-f17f-4d6e-89b5-5990096bcfb0       <NA>
#> 10 505a0c47-b849-4f9e-bd05-d27ef23ef4bd       <NA>
#> 11 65705fb7-b133-4b4e-96f1-7d98d1e4d3f6       <NA>
#> 12 e3d17af6-dce0-4745-a62c-71d99690b322       <NA>

Collects taxonomic data for a name.

name_taxonomy(uuid = "f3254fbd-284f-46c1-ae0f-685549a6a373", options = "string", as = "list")
#> $taxa
#> $taxa[[1]]
#> $taxa[[1]]$canonicalName
#> $taxa[[1]]$canonicalName$uid
#> [1] "f3254fbd-284f-46c1-ae0f-685549a6a373"
#> 
#> $taxa[[1]]$canonicalName$string
#> [1] "Macrauchenia patachonica Owen 1838"
#> 
#> 
#> 
#> 
#> $uBioCommands
#> [1] FALSE
#> 
#> $inclusions
#> list()

Work with name sets

Retrieves information on a set of taxonomic names.

id <- "8d9a9ea3-95cc-414d-1000-4b683ce04be2"
nameset_get(uuid = id, options = c('names', 'string'))
#> $uid
#> [1] "8d9a9ea3-95cc-414d-1000-4b683ce04be2"
#> 
#> $names
#> $names[[1]]
#> $names[[1]]$uid
#> [1] "105d17a4-9706-4fd5-85d7-becffaf6250a"
#> 
#> $names[[1]]$string
#> [1] "Homo sapiens sapiens Linnaeus 1758"
#> 
#> 
#> $names[[2]]
#> $names[[2]]$uid
#> [1] "9dc78907-02ca-4e98-95d7-f5a7c6166ee8"
#> 
#> $names[[2]]$string
#> [1] "Canis familiaris familiaris"

Collects taxonomic data for a name.

nameset_taxonomy(uuid = "8d9a9ea3-95cc-414d-1000-4b683ce04be2", options = "string")$taxa[1:2]
#> [[1]]
#> [[1]]$canonicalName
#> [[1]]$canonicalName$uid
#> [1] "2265ff9d-cfcf-4bf4-9f3e-fb4dd9e90261"
#> 
#> [[1]]$canonicalName$string
#> [1] "Choanozoa"
#> 
#> 
#> 
#> [[2]]
#> [[2]]$canonicalName
#> [[2]]$canonicalName$uid
#> [1] "b909eda2-4a6d-4d87-a463-87cbe3d20c5f"
#> 
#> [[2]]$canonicalName$string
#> [1] "Coelomata"

Work with images

Get info on an image

id <- "9fae30cd-fb59-4a81-a39c-e1826a35f612"
image_get(uuid = id)
#> $uid
#> [1] "9fae30cd-fb59-4a81-a39c-e1826a35f612"

Count images in Phylopic database

image_count()
#> [1] 2870

Lists images in chronological order, from most to least recently modified

image_list(start=1, length=2)
#> [[1]]
#> [[1]]$uid
#> [1] "22e65f52-2e0c-47b2-b4c9-03bdbac84584"
#> 
#> 
#> [[2]]
#> [[2]]$uid
#> [1] "822c549b-b29b-47eb-9fe3-dc5bbb0abccb"

Lists images within a given time range, from most to least recent

image_timerange(from="2013-05-11", to="2013-05-12", options='credit')[1:2]
#> [[1]]
#> [[1]]$credit
#> [1] "Emily Willoughby"
#> 
#> [[1]]$uid
#> [1] "58daaa49-e699-448d-9553-ceedd1fc98a4"
#> 
#> 
#> [[2]]
#> [[2]]$credit
#> [1] "Gareth Monger"
#> 
#> [[2]]$uid
#> [1] "303ddff0-6a51-4f70-adf7-69bb22385d6d"

Work with uBio data

ubio_get(namebankID = 109086)
#> $uid
#> [1] "1ee65cf3-53db-4a52-9960-a9f7093d845d"

Plot a silhouette behind a plot

library('ggplot2')
img <- image_data("27356f15-3cf8-47e8-ab41-71c6260b2724", size = "512")[[1]]
qplot(x = Sepal.Length, y = Sepal.Width, data = iris, geom = "point") +
  add_phylopic(img)

Plot images as points in a plot

For ggplot2 graphics...

library('ggplot2')
img <- image_data("c089caae-43ef-4e4e-bf26-973dd4cb65c5", size = "64")[[1]]
p <- ggplot(mtcars, aes(drat, wt)) +
      geom_blank() +
      theme_grey(base_size = 18)
for (i in 1:nrow(mtcars)) {
  p <- p + add_phylopic(img, 1, mtcars$drat[i], mtcars$wt[i], ysize = 0.3)
}
p

and the same plot in base R graphics:

cat <- image_data("23cd6aa4-9587-4a2e-8e26-de42885004c9", size = 128)[[1]]
posx <- runif(50, 0, 1)
posy <- runif(50, 0, 1)
size <- runif(50, 0.01, 0.2)
plot(posx, posy, type = "n", main = "A cat herd")
for (i in 1:50) {
  add_phylopic_base(cat, posx[i], posy[i], size[i])
}

Built on the shoulders of

This wouldn't have been possible without the great work of Hadley Wickham building ggplot2, and Greg Jordan building ggphylo on top of ggplot2.

Meta

By participating in this project you agree to abide by its terms.

Copy Link

Version

Install

install.packages('rphylopic')

Monthly Downloads

701

Version

0.1.9.9321

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Scott Chamberlain

Last Published

November 18th, 2025

Functions in rphylopic (0.1.9.9321)

add_phylopic

Input an image and create a ggplot2 layer to add to an existing plot
add_phylopic_base

Input an image and add to an existing plot made with base graphics
search_images

Search for images for a taxon (via its uuid)
search_text

Text search for uuids
get_image

Get data for an image or many images.
get_names

Get names for uuids.
minimal_supertaxa

Finds the minimal common supertaxa for a list of names.
name

Perform actions with names.
theme_phylo_blank2

Fixed phylogeny blank theme for ggphylo
ubio

Perform actions with uBio data.
nameset

Perform actions with name sets
phylopic_count

Get the total number of PhyloPic images.