Skip to content

Commit

Permalink
Merge branch 'v0.4.0-photobioloy-v0.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
aphalo committed Dec 23, 2024
2 parents 142faec + 0b8a8e5 commit 2747254
Show file tree
Hide file tree
Showing 465 changed files with 11,825 additions and 14,521 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: ggspectra
Type: Package
Title: Extensions to 'ggplot2' for Radiation Spectra
Version: 0.3.14.9000
Date: 2024-12-05
Date: 2024-12-07
Authors@R:
c(
person("Pedro J.", "Aphalo", email = "pedro.aphalo@helsinki.fi", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3385-972X")),
Expand All @@ -19,7 +19,7 @@ LazyLoad: TRUE
ByteCompile: TRUE
Depends:
R (>= 4.1.0),
photobiology (>= 0.11.2),
photobiology (>= 0.11.4.9003),
ggplot2 (>= 3.5.0)
Imports:
photobiologyWavebands (>= 0.5.2),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ editor_options:
wrap: 72
---

# ggspectra 0.4.0

- Update for compatibility with 'photobiology' (>= 0.12.0), which is required.
- `autoplot()` methods no longer support normalization on-the-fly, but existing
normalization is updated when the unit or quantity is modified.
- The argument passed to `idfactor` when plotting multiple spectra stored in
long form, can be used to rename the existing idfactor of the spectral object.

# ggspectra 0.3.15

- Fix a bug in `autotitle()` affecting only collections of spectra where all
Expand Down
23 changes: 9 additions & 14 deletions R/autoplot-calibration-spct.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ autoplot.calibration_spct <-
geom = "line",
time.format = "",
tz = "UTC",
norm = NULL,
norm = NA,
text.size = 2.5,
idfactor = NULL,
facets = FALSE,
Expand All @@ -279,12 +279,9 @@ autoplot.calibration_spct <-
object.label = deparse(substitute(object)),
na.rm = TRUE) {

if (is.null(idfactor)) {
idfactor <- getIdFactor(object)
}
if (is.na(idfactor) || !is.character(idfactor)) {
idfactor <- getMultipleWl(object) > 1L
}
force(object.label)
warn_norm_arg(norm)
idfactor <- check_idfactor_arg(object, idfactor = idfactor)

if (plot.data != "as.is") {
return(
Expand Down Expand Up @@ -312,8 +309,6 @@ autoplot.calibration_spct <-
)
}

force(object.label)

annotations.default <-
getOption("photobiology.plot.annotations",
default = c("boxes", "labels", "colour.guide", "peaks"))
Expand Down Expand Up @@ -361,8 +356,7 @@ autoplot.calibration_mspct <-
...,
range = getOption("ggspectra.wlrange", default = NULL),
unit.out = "ignored",
norm = getOption("ggspectra.normalize",
default = "skip"),
norm = NA,
pc.out = getOption("ggspectra.pc.out", default = FALSE),
plot.data = "as.is",
idfactor = TRUE,
Expand All @@ -371,8 +365,9 @@ autoplot.calibration_mspct <-
na.rm = TRUE) {

force(object.label)
warn_norm_arg(norm)
idfactor <- check_idfactor_arg(object, idfactor = idfactor, default = TRUE)

idfactor <- validate_idfactor(idfactor = idfactor)
# We trim the spectra to avoid unnecessary computations later
if (!is.null(range)) {
object <- trim_wl(object, range = range, use.hinges = TRUE, fill = NULL)
Expand All @@ -395,7 +390,7 @@ autoplot.calibration_mspct <-
unit.out = unit.out,
norm = norm,
pc.out = pc.out,
idfactor = idfactor,
idfactor = NULL, # use idfactor already set in z
facets = facets,
object.label = object.label,
na.rm = na.rm,
Expand All @@ -408,7 +403,7 @@ autoplot.calibration_mspct <-
unit.out = unit.out,
norm = norm,
pc.out = pc.out,
idfactor = idfactor,
idfactor = NULL, # use idfactor already set in z
facets = facets,
object.label = object.label,
na.rm = na.rm,
Expand Down
40 changes: 10 additions & 30 deletions R/autoplot-cps-spct.r
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ autoplot.cps_spct <-
w.band = getOption("photobiology.plot.bands",
default = list(UVC(), UVB(), UVA(), PhR())),
range = getOption("ggspectra.wlrange", default = NULL),
norm = "skip",
norm = NA,
unit.out = NULL,
pc.out = getOption("ggspectra.pc.out", default = FALSE),
label.qty = "mean",
Expand All @@ -271,12 +271,10 @@ autoplot.cps_spct <-
object.label = deparse(substitute(object)),
na.rm = TRUE) {

if (is.null(idfactor)) {
idfactor <- getIdFactor(object)
}
if (is.na(idfactor) || !is.character(idfactor)) {
idfactor <- getMultipleWl(object) > 1L
}
force(object.label)
warn_norm_arg(norm)
idfactor <- check_idfactor_arg(object, idfactor)
object <- rename_idfactor(object, idfactor)

if (plot.data != "as.is") {
return(
Expand Down Expand Up @@ -304,22 +302,12 @@ autoplot.cps_spct <-
)
}

force(object.label)

annotations.default <-
getOption("photobiology.plot.annotations",
default = c("boxes", "labels", "colour.guide", "peaks"))
annotations <- decode_annotations(annotations,
annotations.default)
# avoid warning in 'photobiology' (== 0.10.10)
if (is.character(norm) && norm == "update" && !is_normalized(object)) {
norm <- "skip"
}
# normalization skipping is handled by normalize()
object <- photobiology::normalize(x = object,
range = range,
norm = norm,
na.rm = na.rm)

if (length(w.band) == 0) {
if (is.null(range)) {
w.band <- waveband(object)
Expand Down Expand Up @@ -370,24 +358,16 @@ autoplot.cps_mspct <-
na.rm = TRUE) {

force(object.label)
warn_norm_arg(norm)
idfactor <- check_idfactor_arg(object, idfactor = idfactor, default = TRUE)

idfactor <- validate_idfactor(idfactor = idfactor)
# We trim the spectra to avoid unnecessary computations later
if (!is.null(range)) {
object <- photobiology::trim_wl(object,
range = range,
use.hinges = TRUE,
fill = NULL)
}
# We apply the normalization to the collection if it is to be bound
# otherwise normalization is applied to the "parallel-summary" spectrum
if (plot.data == "as.is") {
object <- photobiology::normalize(object,
range = getOption("ggspectra.wlrange", default = NULL),
norm = norm,
na.rm = na.rm)
norm <- "skip"
}
# we convert the collection of spectra into a single spectrum object
# containing a summary spectrum or multiple spectra in long form.
z <- switch(plot.data,
Expand All @@ -405,7 +385,7 @@ autoplot.cps_mspct <-
range = getOption("ggspectra.wlrange", default = NULL),
norm = norm,
pc.out = pc.out,
idfactor = idfactor,
idfactor = NULL, # use idfactor already set in z
facets = facets,
object.label = object.label,
na.rm = na.rm,
Expand All @@ -417,7 +397,7 @@ autoplot.cps_mspct <-
range = getOption("ggspectra.wlrange", default = NULL),
norm = norm,
pc.out = pc.out,
idfactor = idfactor,
idfactor = NULL, # use idfactor already set in z
facets = facets,
object.label = object.label,
na.rm = na.rm,
Expand Down
Loading

0 comments on commit 2747254

Please sign in to comment.