0

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 ?

fr4ktus
  • 5
  • 5
  • 1
    If I were you I would include some code to show [what you have already tried](http://mattgemmell.com/2008/12/08/what-have-you-tried/) and ensure that your example code is [reproducible](http://stackoverflow.com/q/5963269/1478381). This is very vague as it stands. – Simon O'Hanlon Apr 26 '13 at 10:23

1 Answers1

1
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.

enter image description here

plannapus
  • 18,529
  • 4
  • 72
  • 94