This question already has an answer here:
- Overlay grid rather than draw on top of it 3 answers
I would like to know if there is a way to let ggplot draw its grid lines in front of the plotted data. As far as I know, I can format almost everything easily by using theme() which works well so far. However, I don't find the option in which order the elements are drawn. I could introduce additional lines to the plot which need to be formatted (coordinates, line groups, etc.) beforehand. Sounds more complicated as it need to be. So I hope, I can modify the plot-grid itself to do the job.
An example of how I am usually plotting the data frame sf.df
of the loaded shapefile sf
:
(ggplot(sf.df, aes(x=long, y=lat))
+ geom_polygon(data=sf.df, aes(group=group, fill=NFK))
+ theme(panel.grid.major=element_line(colour="black"))
+ coord_map(xlim=c(7.08, 7.14), ylim=c(50.93, 50.96))
)
Thank you in advance!