Skip to content

Funcational limits on non-position discrete scales refer to non-existent field trans #3448

Closed
@paleolimbot

Description

@paleolimbot

Thanks to #3426 we can now use functional limits on discrete position scales. However, when using them on non-position discrete scales, there is an error:

library(ggplot2)
ggplot(mpg, aes(displ, hwy, col = class)) +
  geom_point() +
  scale_colour_discrete(limits = rev)
#> Error in self$trans$transform(self$limits(self$trans$inverse(self$range$range))): attempt to apply non-function

The issue is that the default implementation of Scale$get_limits() refers to self$trans, which isn't defined for discrete scales. One way to fix this is to move the default implementation to ScaleContinuous and move the implementation in ScaleDiscretePosition that was added in #3426 to ScaleDiscrete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorscales 🐍

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions