rggplot2maps

Color a specific country in a map


I'm trying to color a specific country (France) on this map and I don't know how to do it. Please help me! Thank you!

library(rnaturalearth)
library(sf)
library(ggplot2)

world <- ne_countries(scale = 50, returnclass = 'sf')
ggplot(world) + geom_sf(aes(fill = continent), color = 'black')+ coord_sf(crs = st_crs(3035),
           xlim = c(2800000, 6200000), 
           ylim = c(1500000, 4000000)) +
scale_fill_manual(values = c('grey', NA, 'grey','grey', NA, NA, NA, NA), guide = 'none', na.value = 'white') + theme(panel.background = element_rect(),panel.grid.major = element_line(linewidth = 0.1))

Solution

  • Set the fill manually to France:

    ggplot(world) + 
      geom_sf(aes(fill = name))+ 
      coord_sf(crs = st_crs(3035), xlim = c(2800000, 6200000), ylim = c(1500000, 4000000)) +
      scale_fill_manual(values = c("France" = "red"), na.value = "grey")
    

    enter image description here