You may have found a bug. If you specify an aesthetics mapping (again), it will work:
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() p + geom_vline(aes(x=wt, y=mpg), xintercept="mean", stat="vline")
The typical ggplot2 documentation is somewhat sparse, making it difficult to evaluate whether this is intentional.
source share