Thanks you both, very useful!
On 25/07/14 03:20, "David Winsemius" <dwinsem...@comcast.net> wrote: > >On Jul 24, 2014, at 2:05 PM, Julien Million wrote: > >> Hi, >> >> i want to automatise the creation of some maps with R, however, I would >>need >> to be able to retrieve the coordinates of the axes that R is >>automatically >> generated. >> >> When using the package MAPS, > >Case matters in R so this is the wrong spelling. > >> and creating a map, R will automatically adjust >> the plot to the region that you are plotting. >> >> for example the two command: >> map(regions="Morocco") >> or >> map(regions="France") >> will generate plots with completely different axis and scale. If I want >>to >> automatically generate a map and add a legend to it, I would need to be >>able >> to retrieve the coordinates of my axis that were automatically >>generated in >> order to give coordinate to place my legend on the map. >> >> Basically I would like to automatise the following with a function, and >>be >> able to automatically get the coordinates for my legend) >> > >require(maps) >> map(regions="Morocco") >> map.axes() >> legend(-12,34, "blablabla") > >Perhaps something like this: >legend(-12,35.5, paste( paste("Xrange = ", round( par("usr")[1:2],2), >collapse=" "), > paste( "Yrange = ", round( par("usr")[3:4],2) , >collapse=" "), > sep="\n") ) > >?par # since pkg::maps uses base graphics. > >> >> map(regions="France") >> map.axes() >> legend(-150,40, "blablabla") >> >> mapcountry <- function(country) { >> map(regions=country) >> map.axes() >> legend(xxxx, yyyy, "blablabla") >> } >> >> I want to be able to extract the xxxx and yyyy automatically to be able >>to >> generate the legend within the function. >> >> Thanks >> >> Julien >> >> >> >> [[alternative HTML version deleted]] > >r-help is a plain text mailing list. >> >> PLEASE do read the posting guide >>http://www.R-project.org/posting-guide.html > >And thank you for providing working code. >-- >David Winsemius >Alameda, CA, USA > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.