I want to add the minor gridlines and tickmarkers (Shorter sticks and without ticklabels) to my map plot, I used scale_x_continuous(minor_breaks = ....), but this didn't work. I've tried some of the methods here, but that didn't work either.
Does anyone know how to solve this problem?
Here is the code and output figure.
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) +
scale_x_continuous(minor_breaks = seq(-170, 0, by = 10),
breaks = seq(-170, 0, by = 20)
)+
theme_bw()+
theme(
# panel.grid=element_blank(),
plot.background = element_rect(fill = NA, color = NA),
axis.text = element_text(size = 12 ),
panel.background = element_rect(fill = "grey"),
panel.grid = element_line(colour = 'blue', size = 0.5),
axis.ticks.length=unit(.4, "cm"),
)