【发布时间】:2021-07-12 06:48:15
【问题描述】:
我正在尝试使用 naturalearth 数据和 ggplot2 获取世界地图。但是,世界地图的 x 轴上没有显示刻度线和轴刻度线和标签。 AFAIK 这个问题曾经用coord_sf(expand = FALSE) 解决(我有使用这个的旧代码),但它似乎不再起作用。我有一个使用不同格式的解决方法,但希望能够使用 sf 数据来解决。
任何帮助表示赞赏!
library(ggplot2) # version 3.3.4
library(rnaturalearth) # version 0.1.0
library(sf) # version 1.0-1
map <- rnaturalearth::ne_countries(scale = 110, returnclass = "sf")
ggplot() +
geom_sf(data = map) +
coord_sf(expand = FALSE)
当我改变坐标范围时显示网格线
ggplot() +
geom_sf(data = map) +
coord_sf(expand = FALSE,
xlim = c(0,50),
ylim = c(0,50))
【问题讨论】: