Cloud2016 dapengde 用这个 geom_path() require(ggplot2) p <- ggplot(map_data("world"), aes(long,lat,group=group)) + geom_path() p
dapengde Cloud2016 geom_path() 是不行的,在 xlim = c(-140, 120)会出现冗余横线。 geom_path()跟 geom_polygon() 病根儿应该是相同的,只是临床症状有区别:前者出现多余的线,后者出现多余的面。
dapengde Cloud2016 如果不考虑用 ggplot,那就好办了。例如用 maps 包就行: maps::map("world", fill=TRUE, col="white", bg="lightblue", xlim = c(-140, 120)) 这么说来,解决 ggplot 地图问题的方案就是不使用 ggplot 咯……
dapengde Liechi 这又回到了 Base R 定义的问题了: maps 包算是 Base R 吗…… 为了避免无谓的口水战,最后可能会沦为 Tidyverse vs. Non-Tidyverse。所以可能改名叫 TNT 擂台赛。
dapengde 完美解决方案来啦:用 coord_quickmap(): p + coord_quickmap(xlim = lr) 同时满足了我的三个要求:无冗余色块,经纬度均匀,展示随意指定经纬度范围。
Cloud2016 dapengde 顺便补充一下二者区别,来自帮助文档 ?coord_quickmap coord_map projects a portion of the earth, which is approximately spherical, onto a flat 2D plane using any projection defined by the mapproj package. Map projections do not, in general, preserve straight lines, so this requires considerable computation. coord_quickmap is a quick approximation that does preserve straight lines. It works best for smaller areas closer to the equator.