R:在X和Y轴上使用真实的LON/LAT值
生成以下图表
library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(rworldmap)
library(scales)
library(sf)
library(mapdata)
library(maptools)
library(ggthemes)
data(wrld_simpl)
antarctica <- wrld_simpl[wrld_simpl$NAME == "Antarctica", ]
pr <- "+proj=laea +lat_0=-90 +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
antarctica.laea <- spTransform(antarctica, CRS(pr))
antarctica_plot <- ggplot() +
geom_polygon(data = antarctica.laea, aes(x=long, y=lat, group=group), fill = '#003f5c') +
labs( x = "Longitude", y = "Latitude") +
annotation_scale(location = "bl", width_hint = 0.5) +
annotation_north_arrow(location = "bl", which_north = "true",
pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
style = north_arrow_fancy_orienteering) +
theme_wsj()
antarctica_plot
我如何在轴上显示真实的纬度和经度值?
I've generated the following chart with R:
library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(rworldmap)
library(scales)
library(sf)
library(mapdata)
library(maptools)
library(ggthemes)
data(wrld_simpl)
antarctica <- wrld_simpl[wrld_simpl$NAME == "Antarctica", ]
pr <- "+proj=laea +lat_0=-90 +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
antarctica.laea <- spTransform(antarctica, CRS(pr))
antarctica_plot <- ggplot() +
geom_polygon(data = antarctica.laea, aes(x=long, y=lat, group=group), fill = '#003f5c') +
labs( x = "Longitude", y = "Latitude") +
annotation_scale(location = "bl", width_hint = 0.5) +
annotation_north_arrow(location = "bl", which_north = "true",
pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
style = north_arrow_fancy_orienteering) +
theme_wsj()
antarctica_plot
How can I display the real latitude and longitude values on my axis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以解决此操作,将空间多边形
(sp)
转换为简单的功能类(sf)
,并使用geom_sf
而不是geom_polygon
代码>。我找不到函数annotation_scale
和annotation_north_arrow
在任何这些软件包中 btw ...You can solve this transforming the spatial polygon
(sp)
to simple feature class(sf)
and using thegeom_sf
insteadgeom_polygon
. I couldnt find the functionsannotation_scale
andannotation_north_arrow
in any of those packages btw...