Skip to content

Commit 6e972c1

Browse files
authored
Don't attempt to calculate secondary breaks = NULL (#5714)
* Also skip 0-length breaks * add news bullet
1 parent cf43adc commit 6e972c1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
`NA`s (#5623)
66
* Facet evaluation is better at dealing with inherited errors
77
(@teunbrand, #5670).
8+
* Fixed spurious warnings from `sec_axis()` with `breaks = NULL` (#5713).
89

910
# ggplot2 3.5.0
1011

R/axis-secondary.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
247247
range_info <- temp_scale$break_info()
248248

249249
# Map the break values back to their correct position on the primary scale
250-
if (!is.null(range_info$major_source)) {
250+
if (length(range_info$major_source) > 0) {
251251
old_val <- stats::approx(full_range, old_range, range_info$major_source)$y
252252
old_val_trans <- transformation$transform(old_val)
253253

@@ -263,7 +263,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
263263
old_val_trans <- NULL
264264
}
265265

266-
if (!is.null(range_info$minor_source)) {
266+
if (length(range_info$minor_source) > 0) {
267267
old_val_minor <- stats::approx(full_range, old_range, range_info$minor_source)$y
268268
old_val_minor_trans <- transformation$transform(old_val_minor)
269269

0 commit comments

Comments
 (0)