Skip to content

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

Closed
@davidhodge931

Description

@davidhodge931

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions