You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a date axis, geom_vline() will only show if there is data nearby the intercept.
For numeric axes though (y in my example below), if the intercept is off-limit, the plot will extend to show the line, which is the expected behavior.
library(tidyverse)
library(lubridate)
set.seed(1234)
df= tibble(
x= as.Date(0:19, origin=ymd("2022-01-01")),
y=rnorm(20)
)
df %>%
ggplot(aes(x,y)) +
geom_point() +
geom_hline(yintercept=5) +#will show (extends)
geom_vline(xintercept=ymd("2022-01-10")) +#will show (within limits)
geom_vline(xintercept=ymd("2022-03-01")) +#will not show (off-limit without extension)
I imagine that is due to scale_x_date()$aesthetics not including xintercept. In attempt to avoid Chesterton's fence: is there a reason that some position scales don't default to ggplot2:::ggplot_global${x/y}_aes?
I believe this was attempted leading up to the latest release but rolled back because it caused a slew of unexpected issues... but can't remember the PR on top of my head
Uh oh!
There was an error while loading. Please reload this page.
Hi,
When using a date axis,
geom_vline()
will only show if there is data nearby the intercept.For numeric axes though (y in my example below), if the intercept is off-limit, the plot will extend to show the line, which is the expected behavior.
Created on 2022-08-25 with reprex v2.0.2
Session info
A workaround would be to add
geom_blank(aes(x=ymd("2022-03-01")))
but it feels a bit unnecessary.The text was updated successfully, but these errors were encountered: