-
Notifications
You must be signed in to change notification settings - Fork 2k
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
geom_vline should work with non-numeric scales #84
Comments
Here here! For dates, the workaround is to wrap the Date with as.numeric, ala: geom_vline(xintercept=as.numeric(Sys.Date)) |
@HarlanH would you mind contributing a couple of reproducible examples? |
DF <- data.frame(dt = as.Date("2000-01-01")+0:20, val=0:20)
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept=as.Date("2000-01-10"))
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept=as.numeric(as.Date("2000-01-10"))) The first does not have a vertical line; the second does, at the expected location. This was run with 0.8.9. This is not up to a testable example, but it is a start. If you are going to handle non-numeric scales, then this should work as well ggplot(iris, aes(x=Species, y=Sepal.Length)) +
geom_point() +
geom_vline(xintercept="setosa") |
I know this issue is more than 2 years old but I figured I'd add a comment. When using the following code (DF from above in this case): ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(
xintercept = as.numeric(as.Date("2001-01-10"))) One has to be careful that the values used for the x-axis date-values are formatted using the same standard. For instance, if your data-frame DF <- data.frame(dt = as.POSIXct("2000-01-01")+0:20, val=0:20)
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept=as.Date("2000-01-10"))
ggplot(DF, aes(x=dt, y=val)) +
geom_point() +
geom_vline(xintercept=as.numeric(as.Date("2000-01-10"))) For instance, the
This example is trivial since we know that format(as.POSIXct("2001-01-10"), format="%Y-%m-%d") made it a lot more annoying to process when generating plots. It is a really simple tip however if you are running larger sequential list of intercepts and your dataset is large, your memory will burst in tears straight through the roof. |
This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette. |
e.g. date and character
The text was updated successfully, but these errors were encountered: