0
votes

Good evening to everyone! I'm using R to plot some locations where I have available data to process. Some locations are on the dry land, some else in the sea, and I would just plot these last ones on a map. So i thought first to plot all the locations as points, overlapping in a second moment the dry land through the "maps" package. Here's my code:

library(maps)
library(mapdata)
png('mydata.png')
plot(mydata, pch=3, col='red', cex=1)
map('worldHires',c('Italy','France'),xlim=c(lon1,lon2),ylim=c(lat1,lat2),fill=T,col='grey')
map.axes()
title("Investigated area and Sample Points")
dev.off()

Where "mydata" is a matrix containing the lon/lat coordinates of my locations.

Unfortunately, doing like that, the map is totally covering my points...whereas if i first plot the map and then the points (through the command "points") i get in the plot both the locations in the sea as well as in the dry land.

I also would like to know how to set the x and y axis label with the "maps" package if possible.

Any suggestion ?

Thanks a lot

Francesco

1

1 Answers

2
votes

After plotting the points, you should add the map with map(..., add=TRUE)