diff --git a/NEWS.md b/NEWS.md index 0828f7957f..c68d560725 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ `NA`s (#5623) * Facet evaluation is better at dealing with inherited errors (@teunbrand, #5670). +* Fixed spurious warnings from `sec_axis()` with `breaks = NULL` (#5713). # ggplot2 3.5.0 diff --git a/R/axis-secondary.R b/R/axis-secondary.R index 0c3fc4be6a..31ad994398 100644 --- a/R/axis-secondary.R +++ b/R/axis-secondary.R @@ -247,7 +247,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL, range_info <- temp_scale$break_info() # Map the break values back to their correct position on the primary scale - if (!is.null(range_info$major_source)) { + if (length(range_info$major_source) > 0) { old_val <- stats::approx(full_range, old_range, range_info$major_source)$y old_val_trans <- transformation$transform(old_val) @@ -263,7 +263,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL, old_val_trans <- NULL } - if (!is.null(range_info$minor_source)) { + if (length(range_info$minor_source) > 0) { old_val_minor <- stats::approx(full_range, old_range, range_info$minor_source)$y old_val_minor_trans <- transformation$transform(old_val_minor)