From 670bb5ffe5973a595b331c242a47507909f5df7a Mon Sep 17 00:00:00 2001 From: William Gearty Date: Tue, 22 Aug 2023 10:34:52 -0400 Subject: [PATCH] Handle single unlisted images in geom_phylopic --- NEWS.md | 1 + R/geom_phylopic.R | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8cdea0e5..d4150b82 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ * added browse_phylopic function (#60) * added preview argument to get_phylopic (#59) * switched to {maps} package in base R advanced vignette +* geom_phylopic now properly handles a single unlisted image object passed to the "img" parameter (#75) # rphylopic 1.1.1 diff --git a/R/geom_phylopic.R b/R/geom_phylopic.R index ecfb726c..582ad72b 100644 --- a/R/geom_phylopic.R +++ b/R/geom_phylopic.R @@ -68,6 +68,11 @@ geom_phylopic <- function(mapping = NULL, data = NULL, if (!is.logical(remove_background)) { stop("`remove_background` should be a logical value.") } + # We need to do this before passing to the layer + dots <- list(...) + if ("img" %in% names(dots) && (is(dots$img, 'Picture') || is.array(dots$img))) { + dots$img <- list(dots$img) + } layer( data = data, mapping = mapping, @@ -76,10 +81,10 @@ geom_phylopic <- function(mapping = NULL, data = NULL, position = position, show.legend = show.legend, inherit.aes = inherit.aes, - params = list( + params = c( na.rm = na.rm, remove_background = remove_background, - ... + dots ) ) }