Latitude axis labels lost when mapping in ggplot2

76 Views Asked by At

I am working on making a map of North America. When I plot the map, the longitude axis labels show up as they are supposed to but for some unknown reason, the latitude axis labels do not show. How can I get the latitude axis labels to show?

library(ggplot2)
library(ggspatial)
library(dplyr)
library(geodata)
library(sf)
library(tidyr)
library(lubridate)

# Country shapefiles for North America ----
can <- gadm(country = 'CAN', level = 0, path=tempdir()) %>%
  st_as_sf()
usa <- gadm(country = 'USA', level = 0, path=tempdir()) %>%
  st_as_sf()
mex <- gadm(country = 'MEX', level = 0, path=tempdir()) %>%
  st_as_sf()

# Shapes of countries near North America ----
cc <- country_codes()
cca <- cc %>%
  filter(UNREGION1 %in% c('Caribbean','Central America'))
cca <- cca$ISO3
cca <- gadm(country = cca, level = 0, path=tempdir()) %>%
  st_as_sf()
green <- gadm(country = 'GRL', level = 0, path=tempdir()) %>%
  st_as_sf()
rus <- gadm(country = 'RUS', level = 0, path=tempdir()) %>%
  st_as_sf()

# Map of North America ----
ggplot() +
  geom_sf(data = green,
          mapping = aes(geometry = geometry),
          color = "black") +
  geom_sf(data = rus,
          mapping = aes(geometry = geometry),
          color = "black") +
  geom_sf(data = can,
          mapping = aes(geometry = geometry),
          color = "black") +
  geom_sf(data = usa,
          mapping = aes(geometry = geometry),
          color = "black") +
  geom_sf(data = cca,
          mapping = aes(geometry = geometry),
          color = "black") +
  geom_sf(data = mex,
          mapping = aes(geometry = geometry),
          color = "black") +
  coord_sf(xlim = c(-180, -48), ylim = c(12, 84), expand = F) +
  annotation_scale(location = "bl",
                   width_hint = 0.2,
                   text_cex = 1) +
  annotation_north_arrow(location = "bl",
                         which_north = "true",
                         pad_x = unit(0.15, "in"),
                         pad_y = unit(0.3, "in"),
                         style = north_arrow_fancy_orienteering) +
  theme_bw() +
  theme(plot.margin = grid::unit(c(0,2,0,2), "mm"),
        text = element_text(size = 16),
        axis.text.x = element_text(size = 14, color = "black"),
        axis.text.y = element_text(size = 14, color = "black"),
        panel.grid.major = element_blank(),
        panel.background = element_rect(fill = "lightblue"))

Map produced from code above: enter image description here

0

There are 0 best solutions below