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
?
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)
). Here I added argument font=2
so that they appear in bold which makes them more legible.
Then creating the legend is fairly straight-forward.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.