【发布时间】:2021-03-01 10:58:34
【问题描述】:
我已经成功地创建了一张可以在下面工作的欧洲地图。
-
如何添加具有纬度和经度的数据集(.csv 格式)。我在下面制作了一个虚拟数据集,我需要为每个
Place覆盖纬度/经度,并用x标记metricA和o标记metricB。有什么办法可以做到吗? -
地图非常小,而边距非常大。我尝试根据堆栈溢出R ggplot, remove white margins in ggsave/ggplot 的此示例添加
theme(plot.margin=grid::unit(c(0,0,0,0), "mm")),但是当我在coord_sf(xlim = c(-40, 60), ylim = c(30, 90)) +之前添加它时,我得到一个错误
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found
当我之后添加它时,它不会改变边距以使情节更大。怎么做才能让图形变大,边距变小?
library("ggplot2")
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
ggplot(data = world) +
geom_sf(color = "black", fill = "grey") +
coord_sf(xlim = c(-40, 60), ylim = c(30, 90)) +
ggtitle("Europe") +
xlab('Longitude') + ylab('Latitude'))
数据集:
Place MetricA MetricB Lat Lon
A x 55 -40
B x 60 -20
C x 75 18
D x x 68 3
E x 35 18
F x 74 42
G x 62 -26
H x 30 -30
I x x 69 15
【问题讨论】: