Skip to content

Commit

Permalink
Add warning when size is too small
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Sep 27, 2023
1 parent 1fac8a9 commit a3cfd9b
Show file tree
Hide file tree
Showing 4 changed files with 1,762 additions and 5 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Suggests:
ape,
deeptime,
palmerpenguins,
maps
maps,
sf
Config/testthat/edition: 3
URL: https://rphylopic.palaeoverse.org,
https://github.com/palaeoverse-community/rphylopic,
Expand Down
15 changes: 11 additions & 4 deletions R/geom_phylopic.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,21 @@ GeomPhylopic <- ggproto("GeomPhylopic", Geom,
# Calculate height as percentage of y limits
# (or r limits for polar coordinates)
if ("y.range" %in% names(panel_params)) {
heights <- data$size / diff(panel_params$y.range)
y_diff <- diff(panel_params$y.range)
} else if ("y_range" %in% names(panel_params)) { # exclusive to coord_sf
heights <- data$size / diff(panel_params$y_range)
y_diff <- diff(panel_params$y_range)
} else if ("r.range" %in% names(panel_params)) { # exclusive to coord_polar
heights <- data$size / diff(panel_params$r.range)
y_diff <- diff(panel_params$r.range)
} else {
heights <- data$size
y_diff <- 1
}
if (any(data$size < (y_diff / 1000))) {
warning(paste("Your specified silhouette `size`s are less than 1000 times",
"smaller than your y-axis range. You probably want to",
"use a larger `size`."), call. = FALSE)
}
heights <- data$size / y_diff

# Hack to make silhouettes the full height of the plot
heights[is.infinite(heights)] <- 1

Expand Down
Loading

0 comments on commit a3cfd9b

Please sign in to comment.