Skip to content

Identity function does not position annotations where expected when x = 0 #6493

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 Jun 4, 2025 · 1 comment

Comments

@davidhodge931
Copy link

davidhodge931 commented Jun 4, 2025

Identity function does not position annotations where expected when x = 0. It does when x = -Inf

Not sure if this is a ggplot thing?

library(tidyverse)
library(palmerpenguins)
#> 
#> Attaching package: 'palmerpenguins'
#> The following objects are masked from 'package:datasets':
#> 
#>     penguins, penguins_raw

p <- penguins |>
  ggplot() +
  geom_bar(aes(x = species), ) +
  theme_classic()

p +
  ggplot2::annotate(
    "segment",
    x = I(0),
    xend = I(1),
    y = c(50, 100),
    yend = c(50, 100),
    colour = "red"
  ) +
  coord_cartesian(clip = "off")

p +
  ggplot2::annotate(
    "segment",
    x = I(-Inf),
    xend = I(1),
    y = c(50, 100),
    yend = c(50, 100),
    colour = "red"
  ) +
  coord_cartesian(clip = "off")

Created on 2025-06-05 with reprex v2.1.1

@davidhodge931
Copy link
Author

Just noticed works correctly with DEV ggplot2 :)

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

No branches or pull requests

1 participant