Skip to content

Binned scales do not works with NA limits and cannot be reversed. #5355

@teunbrand

Description

@teunbrand

I apologise for posting two problems in the same issue.

Binned scales cannot be reversed, as reported in r-lib/scales#389.
I expected these scales to be reversible.

library(ggplot2)

p <- ggplot(mtcars) + geom_bar(aes(mpg))

p + scale_x_binned(trans = "reverse")

Moreover, binned scales don't follow the convention where you can set one of the limits to NA to take the 'natural' limit of the data.
I expect this scale to start at 10 and not throw errors.

p + scale_x_binned(limits = c(10, NA))
#> Error in if (zero_range(range)) zero_width else diff(range): missing value where TRUE/FALSE needed

Created on 2023-07-19 with reprex v2.0.2

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