[R] inset one map on top of another map

Yihui Xie xie at yihui.name
Wed Sep 28 00:20:11 CEST 2011


How about the subplot() function in the TeachingDemos package? It is
basically using par() but you do not have to learn all the gory
details.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Tue, Sep 27, 2011 at 2:31 PM, Jean V Adams <jvadams at usgs.gov> wrote:
> I want to overlay a small inset map on top of another map, but I can't
> figure out how to do it.
> For example, here are two different maps:
>
> # map 1 - Ohio
> map("state", region= "ohio")
>
> # map 2 - US with Ohio darkened
> map("state")
> map("state", region="ohio", fill=T, add=T)
>
> I would like to add map 2 as a small inset in the corner of map 1.
> I have tried:
>
> map("state", region= "ohio")
> par(new=TRUE, mar=c(3, 3, 15, 15))
> map("state")
> map("state", region="ohio", fill=T, add=T)
>
> but this seems to erase map 1 and replace it with a full size version of
> map 2.
>
> I can successfully overlay an unrelated plot using similar code:
>
> map("state", region= "ohio")
> par(new=TRUE, mar=c(3, 3, 15, 15))
> plot(1:10, 1:10)
>
> So, there must be something about the maps() function that I'm tripping
> over.
>
> Any suggestions?
>
> I am using R for Windows 2.13.0
> and the maps package version 2.1-5.
>
> Jean
>
>
> `·.,,  ><(((º>   `·.,,  ><(((º>   `·.,,  ><(((º>
>
> Jean V. Adams
> Statistician
> U.S. Geological Survey
> Great Lakes Science Center
> 223 East Steinfest Road
> Antigo, WI 54409  USA
>
>        [[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