[英]R: Plot grouped coordinates on world map
I would like to plot a set of coordinates organized in studies/groups on a world map, specified in a legend. 我想在图例中指定的世界地图上绘制按研究/组组织的一组坐标。 The dataset is organized as follows: AUTHORS |
数据集的组织方式如下: LAT |
拉特| LONG The are multiple coordinates corresponding to one study that do not differ.
长对应于一项研究的多个坐标没有不同。 Is it possible to plot numbers instead of symbols and link them to a legend?
是否可以绘制数字而不是符号并将其链接到图例?
library(maps)
library(mapdata)
test<-data.frame(Authors=(letters[1:9]), LAT=(seq(10,90,by=10)), LONG=(seq(10,90,by=10)))
map('worldHires')
points(test$LONG,test$LAT, col="red")
I have no clue how to extract the info from the authors vector and link it to the lat/long data as part of a legend. 我不知道如何从作者向量中提取信息并将其链接到经/纬度数据,作为图例的一部分。 Does it even work with
points
? 它甚至可以和
points
吗?
library(maps)
library(mapdata)
test<-data.frame(Authors=(letters[1:9]), LAT=runif(9,-90,90), LONG=runif(9,-180,180))
map('worldHires')
text(test$LONG,test$LAT,labels=1:9, col="red", font=2)
legend("bottom",legend=test$Authors, col="red", pch=as.character(1:9), bg="white", ncol=3)
Use text
instead of points
(you can use points
but you will have to choose pch=as.character(1:9)
). 使用
text
代替points
(可以使用points
但是必须选择pch=as.character(1:9)
)。 Here I added argument font=2
so that they appear in bold which makes them more legible. 在这里,我添加了参数
font=2
以便它们以粗体显示,从而使其更清晰易读。
Then creating the legend is fairly straight-forward. 然后创建图例非常简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.