Closed
Description
In the plot below, there are 2 things that are somewhat bothersome:
- The
geom_vline()
doesn't show up if I leave outgeom_segment()
, due to the fact thatxintercept
is a valid aesthetic for a continuous scale, but not a discrete scale. - The
geom_vline()
is right at the edge of the panel, because the discrete limits are expanded from the discrete range, not the continuous range.
The first thing is due to #3342, which I think might be worth fixing at some point. The second thing is the purpose of this issue. Should we change the limit expansion so that discrete scales are expanded from their continuous limits?
library(ggplot2)
ggplot() +
geom_col(aes(x = "foo", y = 2)) +
geom_segment(aes(x = 0, xend = 2, y = 1, yend = 1)) +
geom_vline(xintercept = c(0, 2), colour = "red")
Created on 2023-12-14 with reprex v2.0.2