ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

`scale_x_steps2()` throws an error when labels and breaks are manually specified

Open EBukin opened this issue 1 year ago • 1 comments

Hi! I've noticed an annoying bug.

When data contains enough variance to plot all breaks, scale_fill_steps2() works as expected.

library(ggplot2)
data <- data.frame(x = 1:3)
ggplot(data) + geom_col(aes(x, x, fill = x)) + scale_fill_steps2(breaks = 1:3, labels = 1:3)

However, when number of breaks exceeds the number of unique oobservations, the function fails:

library(ggplot2)
data <- data.frame(x = 1:2)
ggplot(data) + geom_col(aes(x, x, fill = x)) + scale_fill_steps2(breaks = 1:3, labels = 1:3)
#> Error in `scale_fill_steps2()`:
#> ! `breaks` and `labels` have different lengths.

Could this be linked to #4548 ?

EBukin avatar Aug 21 '24 23:08 EBukin