Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bquote support in plot_annotation? #295

Closed
almenal opened this issue Mar 11, 2022 · 2 comments
Closed

bquote support in plot_annotation? #295

almenal opened this issue Mar 11, 2022 · 2 comments
Labels
feature a feature request or enhancement

Comments

@almenal
Copy link

almenal commented Mar 11, 2022

I can use bquote to write plot titles with a mix of math symbols and variable values in them

p1 <- ggplot(mtcars, aes(cyl, mpg)) + geom_point()
avg_disp <- mean(mtcars$disp)
p1+labs(title = bquote(AVG[disp]==.(avg_disp)))

image

However the same is not possible when arranging plots and putting a figure title with plot_annotation()

p1 <- ggplot(mtcars, aes(cyl, mpg)) + geom_point()
p2 <- ggplot(mtcars, aes(gear, mpg)) + geom_boxplot()
avg_disp <- mean(mtcars$disp)
p1 + p2 + plot_annotation(title = bquote(AVG[disp]==.(avg_disp)))

which produces the following error message:

Error in dots_list(..., title = title, subtitle = subtitle, caption = caption,  : 
  object 'AVG' not found
In addition: Warning message:
Continuous x aesthetic -- did you forget aes(group=...)? 

The documentation of plot_annotation does say that title, subtitle and caption should be text strings, so I wouldn't say this is a bug. I'm just curious about what would be a workaround?

Thanks in advance

@EvoLandEco
Copy link

Same issue here, when I was trying to use bquote with plot_annotation, it just gave me an error

@WilliamCipolli
Copy link

Not technically a bug, as mentioned above, but this would be a great feature to add. @almenal I've gotten around this (painstakingly) by using Unicode characters.

@thomasp85 thomasp85 added the feature a feature request or enhancement label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants