diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index cbea44ff..6335e241 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -49,8 +49,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: - any::rcmdcheck, - vdiffr@1.0.5 + any::rcmdcheck needs: check - uses: r-lib/actions/check-r-package@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 92487803..7ea06094 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,7 @@ License: GPL (>= 2) URL: http://pavo.colrverse.com, https://github.com/rmaia/pavo/ BugReports: https://github.com/rmaia/pavo/issues Depends: - R (>= 3.5.0) + R (>= 4.0.0) Imports: cluster, future.apply, @@ -49,8 +49,7 @@ Imports: farver, plot3D, progressr, - sf, - viridisLite + sf Suggests: alphashape3d, imager, @@ -68,5 +67,5 @@ Config/Needs/website: Encoding: UTF-8 Language: en-GB Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index b3a3779d..cb2e7594 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ S3method(as.rimg,"magick-image") S3method(as.rimg,cimg) S3method(as.rimg,default) +S3method(imager::as.cimg,rimg) S3method(merge,rspec) S3method(plot,colspace) S3method(plot,rimg) @@ -56,7 +57,6 @@ export(procimg) export(procspec) export(projplot) export(projpoints) -export(rimg2cimg) export(rimg2magick) export(segplot) export(segspace) @@ -102,7 +102,6 @@ importFrom(graphics,lines) importFrom(graphics,locator) importFrom(graphics,mtext) importFrom(graphics,par) -importFrom(graphics,plot) importFrom(graphics,plot.default) importFrom(graphics,plot.new) importFrom(graphics,plot.window) diff --git a/NEWS.md b/NEWS.md index 299d9717..87df2233 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,17 @@ # pavo 2.10.0 +## NEW FEATURES AND SIGNIFICANT CHANGES + +- the `rimg2cimg()` function has been removed in favour of a custom `as.cimg()` method. + ## MINOR FEATURES AND BUG FIXES - `as.rspec()` now works out of the box with `tibble`, rather than requiring users to pass a standard data.frame. +## INTERNAL CHANGES + +- dependency on the `viridisLite` package has been removed in favour of recent base R functions + # pavo 2.9.0 ## NEW FEATURES AND SIGNIFICANT CHANGES diff --git a/R/aggplot.R b/R/aggplot.R index bc5d9545..faecf89b 100644 --- a/R/aggplot.R +++ b/R/aggplot.R @@ -27,7 +27,7 @@ #' #' @export #' -#' @importFrom graphics legend lines par plot.default polygon +#' @importFrom graphics legend lines par polygon #' @importFrom grDevices adjustcolor #' @importFrom stats sd #' @@ -137,9 +137,11 @@ aggplot <- function(rspecdata, by = NULL, FUN.center = mean, FUN.error = sd, lcol <- rep(lcol, ncol(cntplotspecs)) } - col_list <- c( - "#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", - "#FF7F00", "#FFFF33", "#A65628", "#F781BF" + col_list <- grDevices::palette.colors( + ncol(cntplotspecs), + palette = "Okabe-Ito", + alpha = 1, + recycle = TRUE ) col_list <- rep_len(col_list, dim(cntplotspecs)[2]) diff --git a/R/as.rimg.R b/R/as.rimg.R index 9f1d2c1b..f66d4e7e 100644 --- a/R/as.rimg.R +++ b/R/as.rimg.R @@ -213,15 +213,15 @@ NULL #' @rdname img_conversion #' -#' @export -rimg2cimg <- function(image) { +#' @exportS3Method imager::as.cimg +as.cimg.rimg <- function(image) { ## Check for imager if (!requireNamespace("imager", quietly = TRUE)) { stop("Package \"imager\" needed for conversion to cimg. Please install it.", call. = FALSE ) } - suppressWarnings(imager::as.cimg(image, cc = 3)) + NextMethod("as.cimg", image, cc = 3) } #' @rdname img_conversion #' diff --git a/R/explorespec.R b/R/explorespec.R index 171fcf2f..6c362b94 100644 --- a/R/explorespec.R +++ b/R/explorespec.R @@ -102,7 +102,7 @@ explorespec <- function(rspecdata, by = NULL, arg$x <- wl if (is.null(arg$col)) { - col_list <- viridisLite::viridis(max(table(by))) + col_list <- grDevices::hcl.colors(max(table(by))) } else { col_list <- arg$col } diff --git a/R/jndplot.R b/R/jndplot.R index 4d35526e..774e8faf 100644 --- a/R/jndplot.R +++ b/R/jndplot.R @@ -38,7 +38,7 @@ #' #' @export #' -#' @importFrom graphics plot.default par plot.default points arrows +#' @importFrom graphics par points arrows #' @importFrom grDevices trans3d #' #' @keywords internal diff --git a/R/pavo-package.R b/R/pavo-package.R index 9c299ae2..7a793871 100644 --- a/R/pavo-package.R +++ b/R/pavo-package.R @@ -1,7 +1,7 @@ #' @keywords internal "_PACKAGE" -#' @importFrom graphics plot +#' @importFrom graphics plot.default # This functions has been moved to base since R 4.0.0 NULL diff --git a/R/plot.rspec.R b/R/plot.rspec.R index 89a65c03..529af76e 100644 --- a/R/plot.rspec.R +++ b/R/plot.rspec.R @@ -99,7 +99,7 @@ plot.rspec <- function(x, select = NULL, type = c("overlay", "stack", "heatmap") } if (is.null(arg$col)) { - arg$col <- viridisLite::cividis(n) + arg$col <- grDevices::hcl.colors(n, palette = "cividis") } else { jc <- colorRampPalette(arg$col) arg$col <- jc(n) diff --git a/R/plotsmooth.R b/R/plotsmooth.R index 71a2e6de..4d45439b 100644 --- a/R/plotsmooth.R +++ b/R/plotsmooth.R @@ -81,11 +81,12 @@ plotsmooth <- function(rspecdata, minsmooth = 0.05, maxsmooth = 0.20, par(mar = c(2, 2, 2, 2), oma = c(3, 3, 0, 0)) - col_list <- c( - "#000000", "#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", - "#FF7F00", "#ffdd33", "#A65628", "#F781BF" + cols <- grDevices::palette.colors( + n = length(curves), + palette = "Okabe-Ito", + alpha = 1, + recycle = TRUE ) - cols <- col_list[seq_len(curves)] # Creates the smooth data matrix for (i in seq_len(nplots)) { diff --git a/R/procimg.R b/R/procimg.R index 01240d59..8739178b 100644 --- a/R/procimg.R +++ b/R/procimg.R @@ -225,7 +225,7 @@ procimg <- function(image, resize = NULL, rotate = NULL, scaledist = NULL, } # Internal function for calibrating image scale -#' @importFrom graphics plot rasterImage locator +#' @importFrom graphics rasterImage locator #' @importFrom stats dist scaler <- function(image_i, scaledist_i, col, ...) { # Plot diff --git a/man/img_conversion.Rd b/man/img_conversion.Rd index 17e00849..82bc637b 100644 --- a/man/img_conversion.Rd +++ b/man/img_conversion.Rd @@ -2,11 +2,11 @@ % Please edit documentation in R/as.rimg.R \name{img_conversion} \alias{img_conversion} -\alias{rimg2cimg} +\alias{as.cimg.rimg} \alias{rimg2magick} \title{Convert images between class rimg and cimg or magick-image} \usage{ -rimg2cimg(image) +\method{as.cimg}{rimg}(image) rimg2magick(image) } diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 108c79e5..4bf1c3c9 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -1,4 +1,4 @@ -url: http://pavo.colrverse.com +url: https://pavo.colrverse.com home: title: Perceptual Analysis, Visualization and Organization of Spectral Colour Data in R @@ -18,27 +18,24 @@ reference: - '`merge.rspec`' - '`procimg`' - '`procspec`' - - '`rimg2cimg`' - '`spec2rgb`' - '`subset.rspec`' - '`simulate_spec`' + - img_conversion - title: Visualisation desc: "Functions for visualising spectral data, including the results of visual modelling" contents: + - starts_with("plot.") - '`aggplot`' - '`axistetra`' - '`explorespec`' - '`legendtetra`' - - '`plot.colspace`' - - '`plot.rimg`' - - '`plot.rspec`' - '`plotsmooth`' - '`points.colspace`' - '`projplot`' - '`sensdata`' - '`tcsplot`' - - '`plot.sensmod`' - title: Analysis desc: "Functions for analysing spectral data"