[R] Map insets and par(usr) values

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Jun 9 08:31:15 CEST 2014


Please don't post HTML email.. we don't necessarily see what you see when you do that. Read the Posting Guide for more list etiquette.

Have you played with the "usr" coordinates? Have you read the help for the par function? 
The par(usr=...) call is telling base graphics what the x and y coordinates of the corners of the graphics window should be. If you subtract the same number from x1 and x2 you will shift the inset to the right because the coordinates of the left edge of the window will be further to the left of the map and the right edge of the window will be closer to the map on the right.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On June 8, 2014 9:29:02 PM MDT, Carly Muletz <craemuletz at gmail.com> wrote:
>This is in reference to the post here by Ray Brownrigg:
>http://r.789695.n4.nabble.com/inset-one-map-on-top-of-another-map-td3848752.html
>
>using this code with the maps package:
>
>map("state", region= "ohio", xlim=c(-85, -80), ylim=c(38, 42))
>par(usr=c(-216, -66, 24, 144))   # you should be able to 'automate'
>this
>calculation
>map("state", add=T)
>map("state", region="ohio", fill=T, add=T)
>
>*MY issue*: I can't figure out how to determine which values to specify
>for
>par(usr=c(______))
>
>I can get the values of the plot area using
>
>par("usr")
>
>But I don't know how to resize the second map or move it to another
>location. When I adjust the values specified it just seems to stretch
>the second map out.
>
>Here is a basic idea of what I am trying to do
>
>library(maps)
>map('state', xlim = c(-86.5,-74), ylim= c(32,41.25), col = "white",
>fill =
>T)
>
>par(usr=c(-216, -66, 24, 144))
>par(xpd=T)
>
>map("state",  xlim = c(-105,-70), ylim= c(25,48), add = T)
>
>---but I would like the US map to be larger and moved to the right
>
>Thanks!
>
>Carly
>
>	[[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.



More information about the R-help mailing list