# load libraries
library(palmerpenguins)
library(tidyverse)
# install.packages('rsvg')
# remotes::install_github('coolbutuseless/ggsvg')
library(rsvg)
library(ggsvg)
Using Icons in Figures with {ggsvg}
graph aesthetics
Abstract
Learn how to insert icons into your plots using the {ggsvg}
package.
Have you ever seen a figure with cute little icons representing data points and thought how you would love to recreate that? I’m here to tell you that you can and the ggsvg
package makes it super simple.
All you have to do is:
Load in the
ggsvg
packageFigure out which icon you want to use from the ones available here
Save the url for your chosen icon to read into your gpplot code
Use
geom_point_svg
in your ggplot code referencing your saved url (FC 2022)
Let’s run through an example with the palmerpenguins
dataset (Horst, Hill, and Gorman 2020). Checkout the package website for some more info and fun artwork! We’re going to subset these data to only include female Chinstrap penguins so that we have fewer data points to plot.
References
FC, Mike. 2022. “Ggsvg: SVG Glyphs for Ggplot.” https://github.com/coolbutuseless/ggsvg.
Horst, Allison Marie, Alison Presmanes Hill, and Kristen B Gorman. 2020. “Palmerpenguins: Palmer Archipelago (Antarctica) Penguin Data.” https://doi.org/10.5281/zenodo.3960218.