gpt4 book ai didi

r - 向ggplot map 添加比例尺

转载 作者:行者123 更新时间:2023-12-04 03:58:35 25 4
gpt4 key购买 nike

我在 ggplot2 中制作了这张 map :

library(maptools); library(ggplot2)
data(wrld_simpl)
world <- fortify(wrld_simpl)
worldUk <- subset(world, id=="GBR")
ggplot() +
geom_path(aes(long, lat, group=group), data=worldUk, color="black", fill=NA) +
coord_equal()

enter image description here

使用 Photoshop,我在 map 上添加了比例尺。如何使用 ggplot2 添加类似的比例尺?这篇文章添加了一个比例尺,但该条不指距离: scale bar and north arrow on map-ggplot2

最佳答案

有一个包叫 ggsn ,它允许您自定义比例尺和指北针。

ggplot() +
geom_path(aes(long, lat, group=group), data=worldUk, color="black", fill=NA) +
coord_equal() +
ggsn::scalebar(worldUk, dist = 100, st.size=3, height=0.01, dd2km = TRUE, model = 'WGS84')
enter image description here

关于r - 向ggplot map 添加比例尺,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17151024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com