Skip to content

position_dodge not working well with preserve = "single" and geom_text (or geom_point) #5995

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

Closed
davidhodge931 opened this issue Jul 11, 2024 · 1 comment · Fixed by #6000
Closed

Comments

@davidhodge931
Copy link

In CRAN version, it doesn't manage to dodge the text correctly...

library(tidyverse, quietly = TRUE)
#> Warning: package 'ggplot2' was built under R version 4.4.1
library(palmerpenguins, quietly = TRUE)

penguins |>
  count(species, sex) |>
  ggplot(
    aes(x = sex,
        y = n,
        fill = species,
        label = n),
  ) +
  geom_col(
    position = position_dodge(preserve = "single"),
    width = 0.75,
    alpha = 0.9,
  ) +
  geom_text(
    colour = "black",
    position = position_dodge(width = 0.75, preserve = "single"),
    vjust = 1.33,
  )
#> Warning in max(table(panel$xmin)): no non-missing arguments to max; returning
#> -Inf

Created on 2024-07-12 with reprex v2.1.0

With DEV version downloaded just now, it errors
image

@davidhodge931 davidhodge931 changed the title position_dodge issues with preserve = "single" with geom_text position_dodge now working well with preserve = "single" with geom_text Jul 11, 2024
@teunbrand
Copy link
Collaborator

Thanks for the report David! I'm surprised that also the old version has buggy dodging, but that might explain why it is missing from the test suite 😅 Not sure if the old version it is the same issue as #3022.
But yeah, should probably get fixed!

@davidhodge931 davidhodge931 changed the title position_dodge now working well with preserve = "single" with geom_text position_dodge not working well with preserve = "single" with geom_text Jul 11, 2024
@davidhodge931 davidhodge931 changed the title position_dodge not working well with preserve = "single" with geom_text position_dodge not working well with preserve = "single" and geom_text (or geom_point) Jul 11, 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

Successfully merging a pull request may close this issue.

2 participants