小编Mel*_*l M的帖子

使用 geom_sf() 绘制世界地图时缺少轴刻度和标签

在绘制基本世界地图时,我没有在坐标轴上显示纬度和经度。我已经完成了 on cran 提供的一个示例geom_sf(),它确实显示了经纬度。

这是我下面的代码。

library("ggplot2")
library("sf")
#> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
library("rnaturalearth")
library("rnaturalearthdata")

world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
#> [1] "sf"         "data.frame"

ggplot(data = world) +
  geom_sf() +
  coord_sf()
Run Code Online (Sandbox Code Playgroud)

这是在轴上生成经纬度的示例代码。

nc <- st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source `/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf/shape/nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -84.32385 ymin: 33.88199 …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 r-sf

4
推荐指数
1
解决办法
1923
查看次数

标签 统计

ggplot2 ×1

r ×1

r-sf ×1