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

Size of text/label keys #5562

Merged
merged 5 commits into from
Dec 8, 2023
Merged

Size of text/label keys #5562

merged 5 commits into from
Dec 8, 2023

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5561.

Briefly, it uses the mechanism introduced in #5465 to communicate the proper width and height of the grobs.
As a detail, since the labelGrob uses the rotation through the viewport, size has to be calculated after manual rotation.

Reprex from #5561:

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

ggplot(mpg, aes(displ, hwy, label = class, colour = class)) +
  geom_text(angle = 45) +
  discrete_scale(
    "label", palette = identity_pal(), super = ScaleDiscreteIdentity
  )

ggplot(mpg, aes(displ, hwy, label = class, colour = class)) +
  geom_label(angle = -45) +
  discrete_scale(
    "label", palette = identity_pal(), super = ScaleDiscreteIdentity
  )

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

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Dec 8, 2023
@teunbrand
Copy link
Collaborator Author

Selfishling adding this to the milestone because I like to use this myself.

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

@teunbrand teunbrand merged commit e51ca46 into tidyverse:main Dec 8, 2023
12 checks passed
@teunbrand teunbrand deleted the text_key_size branch December 8, 2023 12:23
@teunbrand
Copy link
Collaborator Author

Thanks for the review!

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.

We can do better text/label keys now
2 participants