我想画一张半个南极洲的Map。我需要绘制西半部(罗斯海的一半),从120ºE到60ºW。
我使用了similar question的参考代码来制作下图:
我已经包含了我用来制作下图的代码。要在120ºE到60ºW的线上将此Map切成两半,我尝试过
coord_map("ortho", orientation = c(-90, 210, 0), xlim = (120,-60)) +
其仅切除纬度+经度线的一些区段;
scale_x_continuous(limits = c(120, -60), breaks = NULL) +
这是接近,并作出了这个数字(这是错误的1/2):
以及这些代码的很多很多次迭代(是的,我试过交换到c(-60,120),这使得一个空白的Map上有lat +长的线条)。我可以裁剪图像,我可能会诉诸,但我想找到“正确”的解决方案。以下是我的完整参考代码:
library("cowplot")
library("googleway")
library("ggplot2")
library("ggrepel")
library("ggspatial")
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
library("raster")
library("mapproj")
library("rgdal")
# Defines the x axes required
x_lines <- seq(-120,180, by = 60)
wm <- map_data("world")
# Whole Map
ggplot() +
geom_polygon(data = wm, aes(x = long, y = lat, group = group), fill = "grey", colour = "black", alpha = 0.8) +
# Convert to polar coordinates
coord_map("ortho", orientation = c(-90, 210, 0)) +
scale_y_continuous(limits=c(-90,-60), breaks = seq(-45, -90, by = -10), labels = NULL) +
# Removes Axes and labels
scale_x_continuous(breaks = NULL) +
xlab("") +
ylab("") +
# Adds labels
geom_text(aes(x = 90, y = seq(-55, -85, by = -10), hjust = -0.2, label = paste0(seq(55, 85, by = 10), "°S"))) +
geom_text(aes(x = x_lines, y = -63, label = c("120°W", "60°W", "0°", "60°E", "120°E", "180°W"))) +
# Adds axes
geom_hline(aes(yintercept = -60), size = 1) +
geom_segment(aes(y = -60, yend = -90, x = x_lines, xend = x_lines), linetype = "dashed") +
# Change theme to remove axes and ticks
theme(panel.background = element_blank(),
panel.grid.major = element_line(size = 0.25, linetype = 'dashed',colour = "black"),
axis.ticks=element_blank())
2条答案
按热度按时间vhipe2zx1#
也许这就是你要找的。要获取Map的上半部分,我使用
xlim = c(-60, -240)
。另外,我已经或已经将x和y尺度的扩展设置为零。此外,我稍微移动了hline
和线段的位置,以防止geom_hline在达到极限时被切断。最后,我添加了一个geom_label
,以在限制内添加60°W
和120°E
的外部标签。igsr9ssn2#
使用{sf}的另一种方法: