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

Possible to use expressions with guide_axis_nested()? #129

Closed
gallagherman opened this issue Sep 26, 2023 · 2 comments
Closed

Possible to use expressions with guide_axis_nested()? #129

gallagherman opened this issue Sep 26, 2023 · 2 comments

Comments

@gallagherman
Copy link

I can use expressions in scale_x_discrete() normally by setting labels = expression(...), but when use guide = axis_nested, using labels doesn't work anymore, because multiple labels are needed and I think the labels are taken directly from interaction() or weave_factors(). How can we use expressions with nested axis labels? Or is there a way to pass multiple custom label elements with expressions to weave_factors?

Expressions in labels Example:

# Single category, not nested data
data <- data.frame(
  Category = factor(c("A", "B", "C", "D")),
  Value = c(10, 20, 15, 25)
)

ggplot(data, aes(x = Category, y = Value)) +
  geom_col() +
  
  scale_x_discrete(labels = expression(
    Category~alpha,
    Category~beta,
    Category~delta,
    Category~gamma)
  )
@teunbrand
Copy link
Owner

Yeah that's right, the text itself is used to parse out the different hierarchy levels, which doesn't work with expressions.
I'm not planning to do any updates to guide_axis_nested(), as I'm working on something similar using functionality that now only lives in dev-ggplot2. Until that arrives, I'm afraid this isn't possible.

@teunbrand
Copy link
Owner

I'll close this as 'not planned' for now

@teunbrand teunbrand closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
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

No branches or pull requests

2 participants