Skip to content

Fix guide_axis_theta() expression label bug #5577

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

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Dec 12, 2023

I apologise for not filing an issue first, but I ran into the following bug.
On the main branch, expressions aren't rendered properly with guide_axis_theta(). You can see in the example below, the subscript and superscript aren't drawn appropriately.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(data.frame(x = 1:2), aes(x, x)) +
  geom_point() +
  coord_radial() +
  scale_x_continuous(
    breaks = c(1.2, 1.8),
    labels = expression(A^2, B[2])
  )

Created on 2023-12-12 with reprex v2.0.2

The same reprex with this PR draws them appropriately:

The implemented fix is easy: instead of taking the native labels as extracted from the scale, we use the validate_labels() function that handles expressions correctly.

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Dec 12, 2023
@teunbrand teunbrand requested a review from thomasp85 December 12, 2023 13:22
@teunbrand teunbrand merged commit 61142ae into tidyverse:main Dec 13, 2023
@teunbrand teunbrand deleted the theta_axis_expressions branch December 13, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants