-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
@teunbrand
Thanks for your dedication to 'ggplot2'. I can see lots of nice and useful enhancements coming!
The new support in (== 3.5.1.9000) of lambdas as arguments to paprameter name of scales breaks support for some calls as returned by bquote(). Expressions still work as before, as works converting the value returned by bquote() with as.expression(). The culprit seems to be specific tilde characters triggering an attempt to interpret the call as a lambda or formula. First reprex below is for 3.5.1.9000 from R-Universe (183e7ad) and the second for 3.5.1 from CRAN. (I haven't tested all possibilities, but hopefully this reprex provides a hint of what could be the problem.)
Additionally 'gganimate' supports calls but not expressions. See 'gganimate' issue #590.
3.5.1.9000
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.5.1.9000'
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = expression("Efficiency "~~(mi~gl^{-1})))ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote("Efficiency"*(mi~gl^{-1})))ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote("Efficiency"~(mi~gl^{-1})))
#> Error in `allow_lambda()`:
#> ! Can't convert `x`, a two-sided formula, to a function.
eff <- "Efficiency"
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote(.(eff)~(mi~gl^{-1})))
#> Error in `allow_lambda()`:
#> ! Can't convert `x`, a two-sided formula, to a function.Created on 2025-03-27 with reprex v2.1.1
3.5.1
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.5.1'
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = expression("Efficiency "~~(mi~gl^{-1})))ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote("Efficiency"*(mi~gl^{-1})))ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote("Efficiency"~(mi~gl^{-1})))eff <- "Efficiency"
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
scale_y_continuous(name = bquote(.(eff)~(mi~gl^{-1})))Created on 2025-03-27 with reprex v2.1.1





