Skip to content

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

Closed
@EBukin

Description

@EBukin

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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions