Skip to content

Text key justification - #5618

Merged
teunbrand merged 3 commits into
tidyverse:rc/3.5.0from
teunbrand:text_key_justification
Jan 4, 2024
Merged

teunbrand merged 3 commits into
tidyverse:rc/3.5.0from
teunbrand:text_key_justification

Conversation

@teunbrand

@teunbrand teunbrand commented Jan 2, 2024 •

Copy link
Copy Markdown
Collaborator

This PR to the RC aims to fix #5614.

Briefly, the issue at hand is that the draw_key_text() and draw_key_label() functions did not know how to handle character-based justification such as "right" or "outward". This PR fixes that by resolving the justification through compute_just().

As a related change, rotate_just() now also handles character justification.

The reprex from #5614:

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

mycars <- mtcars
mycars$name <- rownames(mycars)

ggplot(mycars, aes(wt, mpg, label = name)) +
  geom_text(aes(size = wt), nudge_x = -0.1, hjust = "right")

Created on 2024-01-02 with reprex v2.0.2

@teunbrand
teunbrand changed the base branch from main to rc/3.5.0 January 2, 2024 09:16
@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Jan 2, 2024

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

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 0ee63c3 into tidyverse:rc/3.5.0 Jan 4, 2024
@teunbrand
teunbrand deleted the text_key_justification branch January 4, 2024 08:01
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
* `compute_just()` returns non-characters as-is

* `rotate_just()` handles character justification

* better text legend justification
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.

Error with hjust = "right" when used together with size aesthetic

2 participants