Skip to content

Commit

Permalink
Handle single unlisted images in geom_phylopic
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Aug 22, 2023
1 parent 37a7b9a commit 670bb5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions R/geom_phylopic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
)
}
Expand Down

0 comments on commit 670bb5f

Please sign in to comment.