[R] Map insets and par(usr) values

Greg Snow 538280 at gmail.com
Mon Jun 9 20:25:39 CEST 2014

Here is an example using the subplot function.

map("state", region= "ohio", xlim=c(-85, -80), ylim=c(38, 42))
tmp <- subplot(map("state",add=TRUE), 'bottomright', type='fig',
size=c(0.2,0.2), inset=0.1)
op <- par(fig=tmp$fig)
map("state", region="ohio", fill=T, add=T)

With maps trying to redo the graphics parameters you need to play
around with the settings a little.  subplot works better with
type='fig' with maps.

On Mon, Jun 9, 2014 at 12:31 AM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
> 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:
>>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'
>>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
>>I can get the values of the plot area using
>>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
>>map('state', xlim = c(-86.5,-74), ylim= c(32,41.25), col = "white",
>>fill =
>>par(usr=c(-216, -66, 24, 144))
>>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
>>       [[alternative HTML version deleted]]
>>R-help at r-project.org mailing list
>>PLEASE do read the posting guide
>>and provide commented, minimal, self-contained, reproducible code.
> ______________________________________________
> 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.

Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com

More information about the R-help mailing list