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

New label_glue() function #459

Merged
merged 7 commits into from
Oct 22, 2024
Merged

New label_glue() function #459

merged 7 commits into from
Oct 22, 2024

Conversation

teunbrand
Copy link
Contributor

This PR aims to fix #457.

Briefly, a new label_glue() function is added that uses the glue package to interpolate strings. The only thing users familiar with the glue package should know is that x is the variable that holds the breaks values.

devtools::load_all("~/packages/scales/")
#> ℹ Loading scales
demo_discrete(iris$Species, labels = label_glue("The Iris {x} flower"))
#> scale_x_discrete(labels = label_glue("The Iris {x} flower"))

Created on 2024-10-07 with reprex v2.1.1

@thomasp85 are there some steps to take that will make {marquee} integration more useful?

@teunbrand
Copy link
Contributor Author

Added option to parse the labels to expressions:

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

demo_continuous(c(0, 10), labels = label_glue("'{number(x)}m'^2", parse = TRUE))
#> scale_x_continuous(labels = label_glue("'{number(x)}m'^2", parse = TRUE))

demo_log10(c(1, 1e4), labels = label_glue("10^{log10(x)}", parse = TRUE))
#> scale_x_log10(labels = label_glue("10^{log10(x)}", parse = TRUE))

Created on 2024-10-11 with reprex v2.1.1

@thomasp85
Copy link
Member

in what way do you envision this to interact in a special way with marquee?

I guess using the marquee_glue function would insulate it from messing with custom classes but that would require a dependency on marquee. I think we better wait until marquee is ready for the primelight

@teunbrand
Copy link
Contributor Author

Yeah exactly, the marquee_glue() function is what I was thinking of. If we don't have to integrate with marquee now, I suppose this PR is good to go.

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasp85 thomasp85 merged commit dd2cf2f into r-lib:main Oct 22, 2024
12 checks passed
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.

Feature request: label_glue()
2 participants