Home > database >  Create world map with a specific extent using ggplot2
Create world map with a specific extent using ggplot2

Time:12-03

I want to build a world map from the map_data ggplot2 function, and then crop it to a specific extension.

I am trying to build a world map with this extension:

ext <- data.frame(xmin = -10.57514, xmax = 37.21653, ymin = 29.68319, ymax = 73.22486)

The code that I have used is this:

library(ggplot2)

ggplot(map_data("world"), aes(long, lat))  
  geom_polygon(aes(group = group), color = "white", fill = "lightgray", size = 0.2)  
  theme_void()  
  coord_fixed()  
  scale_x_continuous(limits = c(ext$xmin, ext$xmax))  
  scale_y_continuous(limits = c(ext$ymin, ext$ymax))

This results in:

enter image description here

As you can see, the bottom of the plot (i.e, most of North Africa) is not accurate.

How would you fix that? Many thanks

  • Related