I want to draw a map that is centered on a specific longitude. This is what I've tried:
我想画一张以特定经度为中心的地图。这就是我尝试过的:
require(maps)
require(ggplot2)
require(mapproj)
t <- map_data("world2")
ggplot() +
geom_polygon(data = t, aes(x=long, y = lat, group = group),fill ='gray',color=NA) +
xlab("Longitude") + ylab("Latitude")
Gives map centred at 200 longitude. I want to change it to 180, so that West Africa won't appear on the other opposite of the map. Adding xlim
does not seem to work:
给出了以200经度为中心的地图。我想把它改为180,这样西非就不会出现在地图的另一边。添加xlim似乎不起作用:
ggplot() +
geom_polygon(data = t, aes(x=long, y = lat, group = group),fill ='gray',color=NA) +
xlab("Longitude") + ylab("Latitude") +
coord_cartesian(xlim=c(-20,200))
更多回答
优秀答案推荐
I found a way to do this:
我找到了一种方法:
t <- map_data("world2",wrap=c(-25,335), ylim=c(-35,65))
更多回答
我是一名优秀的程序员,十分优秀!