Skip to content

Commit

Permalink
filter problematic args
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisAJones committed Dec 21, 2023
1 parent 8aa8292 commit 1ded6c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions R/add_phylopic_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#' @details This function can be used to add PhyloPic silhouettes as a
#' legend to a base R plot. Arguments available in [legend()] can be used and

Check warning on line 12 in R/add_phylopic_legend.R

View workflow job for this annotation

GitHub Actions / lint

file=R/add_phylopic_legend.R,line=12,col=78,[trailing_whitespace_linter] Trailing whitespace is superfluous.
#' passed via `...`. Note that not all arguments in [legend()] are compatible
#' with [add_phylopic_legend()], such as `pch`. However, in general,
#' arguments for adjusting the legend appearance (not silhouettes) such as
#' text, legend box, etc. are.
#' with [add_phylopic_legend()], such as `pch` and `lwd`. However, in general,
#' arguments for adjusting the legend appearance such as text (e.g. `cex`),

Check warning on line 15 in R/add_phylopic_legend.R

View workflow job for this annotation

GitHub Actions / lint

file=R/add_phylopic_legend.R,line=15,col=76,[trailing_whitespace_linter] Trailing whitespace is superfluous.
#' legend box (e.g. `bg`), and color (e.g. `border`) are.
#' @importFrom graphics legend
#' @export
#' @examples
Expand All @@ -33,13 +33,21 @@
add_phylopic_legend <- function(img = NULL, name = NULL, uuid = NULL,

Check warning on line 33 in R/add_phylopic_legend.R

View workflow job for this annotation

GitHub Actions / lint

file=R/add_phylopic_legend.R,line=33,col=70,[trailing_whitespace_linter] Trailing whitespace is superfluous.
ysize = NULL, color = NA, fill = "black",

Check warning on line 34 in R/add_phylopic_legend.R

View workflow job for this annotation

GitHub Actions / lint

file=R/add_phylopic_legend.R,line=34,col=74,[trailing_whitespace_linter] Trailing whitespace is superfluous.
...) {
# inherit
leg_pos <- legend(...)
# Extract arguments if provided via legend
# Get supplied arguments
args <- list(...)
# Filter unrequired arguments

Check warning on line 38 in R/add_phylopic_legend.R

View workflow job for this annotation

GitHub Actions / lint

file=R/add_phylopic_legend.R,line=38,col=32,[trailing_whitespace_linter] Trailing whitespace is superfluous.
dump <- c("lty", "lwd", "pch", "angle", "density", "pt.lwd", "merge")
if (any(names(args) %in% dump)) {
args <- args[-which(names(args) %in% dump)]
}
# Do call
leg_pos <- do.call(legend, args)
# Extract arguments if provided via legend for plotting
# color values
col <- args[["col"]]
if (!is.null(col)) color <- col
border <- args[["border"]]
if (!is.null(border)) color <- border
# fill value
bg <- args[["pt.bg"]]
if (!is.null(bg)) fill <- bg
Expand Down
6 changes: 3 additions & 3 deletions man/add_phylopic_legend.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ded6c1

Please sign in to comment.