Closed
Description
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
.