我正在尝试获取一张与图像中看到的类似的马尔地夫地图。然而,我正在与xlim和ylim作斗争。有什么建议吗?
library(cowplot)
library(googleway)
library(ggplot2)
library(ggrepel)
library(ggspatial)
library(libwgeom)
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
theme_set(theme_bw())
ggplot(data = world) +
geom_sf() +
coord_sf(xlim = c(-102.15, -74.12), ylim = c(7.65, 33.97), expand = FALSE)

发布于 2020-08-07 19:03:34
在这种格式下,马尔地夫并不是一个很好的地图,因为它们太小了,而且分布得很广。事实上,如果您使用当前使用的rnaturalearth中的中等分辨率数据,您将只能看到数百个岛屿中的一个或两个,并且它们只会显示为小斑点。
相反,您可以获得如下所示的更高分辨率的贴图:
maldives <- ne_countries("large", country = "Maldives", returnclass = "sf")
theme_set(theme_bw())
ggplot(data = maldives) +
geom_sf() +
coord_sf(xlim = c(70, 76))

如果你只想看到它们的整体形状、范围和位置,你可以展示它们与附近的印度和斯里兰卡国家的关系:
maldives <- ne_countries("large",
country = c("Maldives", "India", "Sri Lanka"),
returnclass = "sf")
theme_set(theme_bw())
ggplot(data = maldives) +
geom_sf() +
coord_sf(xlim = c(72, 82), ylim = c(-1, 15))

另一种选择是给地图上色,让岛屿“弹出”。
ggplot(data = maldives) +
geom_sf(fill = "#55790A", color = "#90FF20") +
coord_sf(xlim = c(72, 82), ylim = c(-1, 15)) +
theme(panel.background = element_rect(fill = "#342255"),
panel.grid = element_line(color = "#4f4f6f"))

或者坚持原来的格式,但放大到首都附近:
ggplot(data = maldives) +
geom_sf() +
coord_sf(xlim = c(72.5, 73.5), ylim = c(6, 7.2))

https://stackoverflow.com/questions/63298810
复制相似问题