library(grid) library(ggplot2) library(svgparser)
Since {svgparser} uses {xml2}, it can load SVG files from a URL.
{svgparser}
{xml2}
Note the linear gradient on the R logo is preserved in the conversion to an R grob object.
rlogo_url <- 'https://www.r-project.org/logo/Rlogo.svg' rlogo <- svgparser::read_svg(rlogo_url) grid.draw(rlogo)
annotation_custom()
ggplot(mtcars) + geom_point(aes(mpg, wt)) + annotation_custom(rlogo, xmin = 28, xmax = 33, ymin = 4, ymax = 5) + labs(title = "svgparser::read_svg() + ggplot2") + theme_bw()