You can use geom_rect
.
... + geom_rect(aes(xmin=159683.438, xmax=159684.186, ymin=0, ymax=Inf))
The two values for x come from your geom_vline
calls. using ymin=0
takes it down to 0; ymax=Inf
will take it all the way to the top of the axis. If you want it to go all the way down to the x axis rather than 0, you can use ymin=-Inf
.
Some notes:
This works best if it is early in the order of geoms so that it gets drawn first/below the other parts (especially the scatterplot data).
You can set the fill color (fill
aesthetic) outside the aes
call to a fixed value. I would also set the transparency (alpha
) to something like 0.5 so that the stuff behind it (grid lines, most likely, if you put it as the first geom) can still be seen.