making an inset in a map figure

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

making an inset in a map figure

Waichler, Scott R-2
Hi, Does anyone have an example of making a map figure with an inset, where a portion of the map in the large figure is shown at a larger scale in the inset?

Scott Waichler
Hydrology Group
Pacific Northwest National Laboratory
Richland, WA, USA

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

Francisco Rodriguez Sanchez
What a coincidence! I was just having a look at this older message from
the list that should solve the problem:
https://stat.ethz.ch/pipermail/r-sig-geo/2012-June/015340.html

Cheers,

Paco


El 10/09/2013 17:00, Waichler, Scott R escribió:

> Hi, Does anyone have an example of making a map figure with an inset, where a portion of the map in the large figure is shown at a larger scale in the inset?
>
> Scott Waichler
> Hydrology Group
> Pacific Northwest National Laboratory
> Richland, WA, USA
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--
Dr Francisco Rodriguez-Sanchez
Forest Ecology and Conservation Group
Department of Plant Sciences
University of Cambridge
Downing Street
Cambridge CB2 3EA
United Kingdom
http://sites.google.com/site/rodriguezsanchezf

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

MacQueen, Don
In reply to this post by Waichler, Scott R-2
Perhaps use subplot() from the Hmisc package

-Don

--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 9/10/13 9:00 AM, "Waichler, Scott R" <[hidden email]> wrote:

>Hi, Does anyone have an example of making a map figure with an inset,
>where a portion of the map in the large figure is shown at a larger scale
>in the inset?
>
>Scott Waichler
>Hydrology Group
>Pacific Northwest National Laboratory
>Richland, WA, USA
>
>_______________________________________________
>R-sig-Geo mailing list
>[hidden email]
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
GD
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

GD
# Something like

library(maptools)
data(wrld_simpl)

plot(wrld_simpl,border=NA,col='blue',axes=T, xlim=c(100,130), ylim=c(-40,30))
par(plt = c(0.2, 0.5, 0.6, 0.8), new = TRUE)
plot(wrld_simpl,border=NA,col='green',bg='white',axes=F)

# If you put axes on the inset, they will fall over the background map -- but, you could fix that by drawing a white rectangle there first (e.g. using rect).
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

Greg Snow-3
In reply to this post by Waichler, Scott R-2
Here is an example using the subplot function:

library(TeachingDemos)
library(maptools)
data(wrld_simpl)

plot(wrld_simpl,border=NA,col='blue',axes=TRUE, xlim=c(100,130),
ylim=c(-40,30))

tmp <- subplot(
   plot(wrld_simpl,border=NA,col='green',bg='white',axes=FALSE),
   'bottomleft', size=c(2,1), inset=c(0.01,0.01))

tmp2 <- par('usr')

tmp3 <- subplot(
plot(wrld_simpl, border='red', axes=TRUE, xlim=c(95,105),
ylim=c(-5,5), bg='lightgrey'),
'topright', size=c(2,2))

par(xpd=TRUE)  # reset clipping region
rect( tmp3$usr[1], tmp3$usr[3], tmp3$usr[2], tmp3$usr[4], border='orange' )

op <- par(tmp[c('plt','usr')])
rect( tmp2[1], tmp2[3], tmp2[2], tmp2[4], border='red' )
par(op)


I use subplot from TeachingDemos, the version in Hmisc is a copy of the one
in TeachingDemos.


On Tue, Sep 10, 2013 at 10:00 AM, Waichler, Scott R <[hidden email]
> wrote:

> Hi, Does anyone have an example of making a map figure with an inset,
> where a portion of the map in the large figure is shown at a larger scale
> in the inset?
>
> Scott Waichler
> Hydrology Group
> Pacific Northwest National Laboratory
> Richland, WA, USA
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

Waichler, Scott R-2
I found some problems with this code, but no worries, I got subplot() working and finished my figure.  The resolution and sharpness of the figure is definitely superior to a version I had been trying to make with ArcMap.


1.        R-3.0.1 didn't find subplot() in TeachingDemos, but it did in Hmisc.

2.       Other glitches:


> tmp <- subplot(
+    plot(wrld_simpl,border=NA,col='green',bg='white',axes=FALSE),
+    'bottomleft', size=c(2,1), inset=c(0.01,0.01))
Error in subplot(plot(wrld_simpl, border = NA, col = "green", bg = "white",  :
  unused argument (inset = c(0.01, 0.01))

> tmp3 <- subplot(
+ plot(wrld_simpl, border='red', axes=TRUE, xlim=c(95,105),
+ ylim=c(-5,5), bg='lightgrey'),
+ 'topright', size=c(2,2))
Error in par(plt = c(xy$x, xy$y), new = TRUE) :
  invalid value specified for graphical parameter "plt"
In addition: Warning message:
In xy.coords(x, y) : NAs introduced by coercion

--Scott

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: making an inset in a map figure

Greg Snow-3
It is really strange that you would not find subplot in TeachingDemos.  Do
you have the latest version of the package (2.9 on CRAN, 2.10 on R-Forge)
installed?

It looks like the version in Hmisc is still the old version before the
addition of being able to specify location using 'topright' and the like.
 The Hmisc version should still work, you just need to specify the location
of the subplot using x and y coordinates instead of a string (and inset
came with the string version).


On Fri, Sep 13, 2013 at 3:32 PM, Waichler, Scott R
<[hidden email]>wrote:

> I found some problems with this code, but no worries, I got subplot()
> working and finished my figure.  The resolution and sharpness of the figure
> is definitely superior to a version I had been trying to make with ArcMap.
> ****
>
> ** **
>
> **1.       ** R-3.0.1 didn’t find subplot() in TeachingDemos, but it did
> in Hmisc.****
>
> **2.       **Other glitches:****
>
> ** **
>
> > tmp <- subplot(****
>
> +    plot(wrld_simpl,border=NA,col='green',bg='white',axes=FALSE),****
>
> +    'bottomleft', size=c(2,1), inset=c(0.01,0.01))****
>
> Error in subplot(plot(wrld_simpl, border = NA, col = "green", bg =
> "white",  :****
>
>   unused argument (inset = c(0.01, 0.01))****
>
> ** **
>
> > tmp3 <- subplot(****
>
> + plot(wrld_simpl, border='red', axes=TRUE, xlim=c(95,105),****
>
> + ylim=c(-5,5), bg='lightgrey'),****
>
> + 'topright', size=c(2,2))****
>
> Error in par(plt = c(xy$x, xy$y), new = TRUE) :****
>
>   invalid value specified for graphical parameter "plt"****
>
> In addition: Warning message:****
>
> In xy.coords(x, y) : NAs introduced by coercion****
>
> ** **
>
> --Scott****
>


--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

        [[alternative HTML version deleted]]


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo