Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

subsetting world map to northern temperate latitudes ggplot2

Tags:

I want to create a map of where my study sites are. All sites are in Northern temperate latitudes. To do this, I first load a world map, then set the y axis to only include northern temperate latitudes (between 23.5 and 66.5 degrees longitude).

#build map
world <- map_data("world") # we already did this, but we can do it again
map <- ggplot() + geom_polygon(data = world, aes(x=long, y = lat, group = group))
map <- map + coord_map(ylim = c(23.5, 66.5))
map

However, this mixes things up at the top of the map, and also places a strangle black line just north of 50 degrees latitude. How can I fix this? enter image description here

like image 1000
colin Avatar asked Apr 16 '18 20:04

colin


1 Answers

You can slice it and use a real projection as well:

library(ggalt)
library(ggplot2)

world <- map_data("world") 

ggplot() +
  geom_cartogram(
    data = world, map = world,
    aes(x=long, y = lat, group = group, map_id=region)
  ) +
  coord_proj("+proj=wintri", ylim = c(23.5, 66.5))

enter image description here

like image 71
hrbrmstr Avatar answered Oct 11 '22 18:10

hrbrmstr