Getting started with rphylopic"

Authors: Lewis A. Jones & William Gearty

Last updated: 2023-10-28

# Introduction **rphylopic** is a package that allows users to easily fetch and visualize silhouettes of organisms from [PhyloPic](https://www.phylopic.org). The package allows users to add silhouettes as layers or as data points to both base R and `{ggplot2}` plots. Additional functionality allows users to pick between available silhouettes, transform them (e.g., rotate and recolor), and save image files. This vignette will give you an overview of the package and provide example usage. ## Installation The **rphylopic** package can be installed via CRAN or its dedicated [GitHub repository](https://github.com/palaeoverse-community/rphylopic) if the development version is preferred. To install via CRAN, simply use: wzxhzdk:0 To install the development version, first install the `{remotes}` package, and then use `install_github()` to install **rphylopic** directly from GitHub. wzxhzdk:1 You can now load **rphylopic** using the default `library()` function: wzxhzdk:2 **Before we get onto the good stuff, the development team has a small request**. If you use **rphylopic** in your research, please cite the associated publication. This will help us to continue our work in supporting you to do yours. You can access the appropriate citation via: wzxhzdk:3 wzxhzdk:4 Also, don't forget to acknowledge the contributors of the silhouettes that you use (see [Get attribution]). # How does it work? Every silhouette available via [PhyloPic](https://www.phylopic.org) has a universally unique identifier (UUID). The first step to get a PhyloPic silhouette into R is to get a UUID. To do so via **rphylopic** you can use the `get_uuid()` function to search [PhyloPic](https://www.phylopic.org) based on a taxonomic or phylogenetic name (e.g., *Canis lupus* or pan-Mollusca) and return the first matched UUID. Using the returned UUID, you can then fetch the respective silhouette using `get_phylopic()`. However, multiple silhouettes (and hence UUIDs) can exist for a searched name. The `n` argument in `get_uuid()` allows you to fetch `n` matched UUIDs. ## Get an image uuid wzxhzdk:5 ## Pick an image As multiple silhouettes can exist for a searched name, it can be difficult to pick the correct UUID, especially without visualizing the images. The `pick_phylopic()` function plots all requested silhouettes and provides an interactive menu to allow you to select the right image for you. Let's go with option 1! wzxhzdk:6 ## Plot an image Now we have selected our silhouette, we can make some plots! ### Base R Let's start with base R by using `add_phylopic_base()`: wzxhzdk:7
plot of chunk intro-base-plot

plot of chunk intro-base-plot

Ah, you've found out our little secret! You can actually skip the steps of getting the UUID altogether by just searching for the desired taxon in `add_phylopic_base()`. However, this will always return the first matched silhouette meaning you might be missing out on all the other options! It's always worth checking out your options with `pick_phylopic()` first. ### ggplot2 You can also accomplish the same plot with the `{ggplot2}` package. Here, we'll use the `add_phylopic()` function, but the functionality and all of the arguments are the same: wzxhzdk:8
plot of chunk intro-ggplot-plot

plot of chunk intro-ggplot-plot

## Transforming silhouettes Once a silhouette is picked and saved in the your R environment, it may be useful to transform the image to better suit the particular visualization of interest. We have implemented three user-friendly functions to accommodate three transformations that might be desired: flipping, rotating, and recoloring. The `flip_phylopic()` function can be used to flip a silhouette horizontally and/or vertically. This may be useful if, for example, you want all of the silhouettes to face the same direction. wzxhzdk:9 The `rotate_phylopic()` function can be used to rotate a silhouette an arbitrary number of degrees. This may be useful when trying to align a silhouette with text or other objects within a figure. wzxhzdk:10 Finally, the `recolor_phylopic()` function can be used to modify the color and/or transparency of a silhouette. The vast majority of PhyloPic silhouettes are black and fully opaque by default. However, it may be useful to change this when the you are trying to either match an existing visualization color palette or trying to convey extra information, such as categorical data, through color. wzxhzdk:11 Let's see what those look like in the same plot: wzxhzdk:12
plot of chunk intro-transform-plot

plot of chunk intro-transform-plot

You'll notice that the rotated silhouette is smaller than the other two silhouettes. This is because our functions have arguments to specify the height (`ysize`). The width is automatically set to maintain the original aspect ratio of the silhouette. In this case, the aspect ratio of the rotated silhouette has changed, so the same height results in a smaller silhouette overall. For convenience, we have also included these transformation options within all of the visualization functions. The default color is "black", hence why we needed to specify `color = "original"` above. However, when the same transformed silhouette will be used for multiple visualizations, we suggest transforming the silhouette first, saving it as a new object, then using this new object for visualization purposes. ## Get attribution Now that you've made a plot and used some silhouettes, you should acknowledge the contributors that made those silhouettes. Fortunately, **rphylopic** includes the `get_attribution()` function to get contributor data about specific images: wzxhzdk:13 wzxhzdk:14 This function can even write a little blurb for you to include in your publications: wzxhzdk:15 wzxhzdk:16 ## Save an image You should be able to accomplish all of your visualization needs within R (see our other vignettes for examples), but in the rare case that need to use a silhouette outside of R, we've also got you covered with the `save_phylopic()` function. You can save silhouettes in a range of formats, including: Portable Document Format (PDF), Portable Network Graphics (PNG), Scale Vector Graphics (SVG), Tag Image File Format (TIFF), Joint Photographic Experts Group (JPEG), and bitmap (BMP). wzxhzdk:17 ## More advanced examples Now that you've learned the ropes of **rphylopic**, how about you check out some more advanced examples? - [Advanced examples in ggplot2](b-advanced-ggplot.html) - [Advanced examples in base R](c-advanced-base.html)


Try the rphylopic package in your browser

Any scripts or data that you put into this service are public.

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