-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
I found a problem with using I() with discrete scale and annotate. The text is placed according to the position in the scale and not to the position in the plot. The same plot works as expected with a continuous scale.
Here is the code to reproduce the bug:
library(ggplot2)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
tibble(
x = sample(0:10, 100, replace = T),
y = sample(letters[1:10], 100, replace = T),
) |>
ggplot(aes(x = x, y = y)) +
geom_point() +
geom_text(
x = I(0.5),
y = I(0.5),
label = "A",
color = "red"
) tibble(
x = sample(0:10, 100, replace = T),
y = sample(0:10, 100, replace = T)
) |>
ggplot(aes(x = x, y = y)) +
geom_point() +
geom_text(
x = I(0.5),
y = I(0.5),
label = "A",
color = "red"
)Created on 2025-07-28 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels

