I want the grid lines to be displayed on top of the picture, so I tried to use geom_hline/geom_vline to do this, but it turned out that the vertical lines do not extend to the northern border of the picture. Is there anything I can do to improve?
Here is the code and output picture.
library("sf")
library("rnaturalearth")
library("tidyverse")
world <- ne_countries(scale = "medium", returnclass = "sf")
usa = filter(world,admin =="United States of America")
# Plot
ggplot() +
geom_sf(data = usa, fill = "lightblue",color = "black",alpha=.9) +
coord_sf(
xlim = c(-119, -74),
ylim = c(22, 51),
default_crs = sf::st_crs(4326),
crs = st_crs("ESRI:102003"),
expand = TRUE,
lims_method = "box",
label_axes = list(
bottom = "E", top = "E",
left = "N", right = "N"
)) +
xlab(NULL) + ylab(NULL) +
### adding grid lines on the top
geom_hline(yintercept = seq(0, 90, by=5),
color = "blue", linetype = "solid", size = 0.5) +
geom_vline(xintercept=seq(-180, 0, by=10),
color = "blue", linetype = "solid", size = 0.5 )+
theme_bw()+
theme(
panel.grid=element_blank(),
plot.background = element_rect(fill = NA, color = NA),
panel.background = element_rect(fill = "grey"),
axis.text = element_text(size = 12 ),
)