[R] Retrieve Axis coordinates from map
Peter Alspach
Peter.Alspach at plantandfood.co.nz
Fri Jul 25 03:15:04 CEST 2014
Tena koe Julien
I don't use the maps package much, but I suspect par()$usr will allow you to do what you want.
HTH ....
Peter Alspach
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Julien Million
Sent: Friday, 25 July 2014 9:05 a.m.
To: r-help at r-project.org
Subject: [R] Retrieve Axis coordinates from map
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, 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)
map(regions="Morocco")
map.axes()
legend(-12,34, "blablabla")
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 at 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.
The contents of this e-mail are confidential and may be ...{{dropped:14}}
More information about the R-help
mailing list