Could continuous colour scale `rescaler` argument work with `\(x) x` notation?
Closed this issue · 3 comments
davidhodge931 commented
It'd be great if rescaler argument could work with \(x) x notation!
library(tidyverse)
library(scales)
p <- mpg |>
ggplot() +
geom_point(
aes(x = displ,
y = hwy,
colour = cty),
)
#works
p +
scale_colour_continuous(
palette = pal_div_gradient("blue", "white", "red"),
rescaler = ~ scales::rescale_mid(.x, mid = 15),
)
#doesn't
p +
scale_colour_continuous(
palette = pal_div_gradient("blue", "white", "red"),
rescaler = \(x) scales::rescale_mid(x, mid = 30),
)
teunbrand commented
It works if you use \(x, ...) instead of \(x).
davidhodge931 commented
Ah thanks!
It feels like it'd be nicer if it could work with (x) x like other functions, if not too difficult
Feel free to close
teunbrand commented
The rescaler gets passed multiple arguments, so I don't think \(x) are appropriate formals to use for the rescaler function.