-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Document vector passing to nudge_y/nudge_x/position_nudge #6335
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! We generally don't want to encourage passing aesthetics outside aes()
as vectors for the reasons documented in most layers like ?geom_point
:
Please note that while passing unmapped aesthetics as vectors is technically possible, the order and required length is not guaranteed to be parallel to the input data.
If you want to pass it like aes(nudge_y = c(...))
that'd be fine with me. If you intend to change the example, would you mind running devtools::document()
so that the changes propagate to the .Rd files?
Sorry, if I am ignorant here, but wrapping
The same error happens when setting |
The development version of ggplot2 understands # Load the development version on my personal machine
devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
df <- data.frame(
x = factor(c(1, 1, 2, 2)),
y = c(1, 3, 2, 1),
grp = c("a", "b", "a", "b")
)
ggplot(df, aes(x, y)) +
geom_point() +
geom_text(aes(label = y, nudge_y = c(-0.1, 0.1, -0.1, 0.1))) Created on 2025-02-21 with reprex v2.1.1 |
As discussed in tidyverse#6355.
Ah, I see. So you might want to change the target branch of this PR to a development branch? I added the change and ran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me: thank you very much for the contribution!
you might want to change the target branch of this PR to a development branch
The main branch is the development branch, the released versions are tagged.
Recently, when creating plots with
ggstatsplot
(using theggbetweenstats
function), I wanted to move the centrality labels for each distribution individually. It took me quite some time to figure out that I can pass a vector tonudge_y
(orposition_nudge
for that matter).Therefore, I propose to document this functionality.