Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To plot multiple maps using rworldmap, you could use layout and a couple of loops to create a plot like this using the code below. </p> <p><img src="https://i.stack.imgur.com/1fnxl.png" alt="rworldmap multi-panel demo"></p> <p>I know loops aren't cool these days but I still think that way. Probably possible to put all this into an apply type function, but the speed of the loops is rarely an issue when plotting.</p> <p>(also see item 19 multi-panel plots in the FAQ <a href="http://cran.r-project.org/web/packages/rworldmap/vignettes/rworldmapFAQ.pdf" rel="nofollow noreferrer">http://cran.r-project.org/web/packages/rworldmap/vignettes/rworldmapFAQ.pdf</a> )</p> <pre><code>library(rworldmap) newmap &lt;- getMap(resolution = "coarse") #'low' or even 'coarse' resolution map may be sufficient #example data for 2 years 6 months each month &lt;- c(1:6,1:6) year &lt;- c(rep(2012,6),rep(2013,6)) lon &lt;- c(120:131) lat &lt;- c(-35:-24) p1 &lt;- data.frame(month=month,year=year,lon=lon,lat=lat) months &lt;- unique(p1$month) years &lt;- unique(p1$year) oldPar &lt;- par(mar=c(2, 0, 0, 2)) #margins top,bottom,left,right #use layout to create multiple panels including space at top for a title nPanels &lt;- layout( cbind(c(0,1:6),c(0,7:12)) , heights=c(lcm(1),rep(1,6)) , respect=F ) for( yrNum in 1:length(years) ) { yr &lt;- years[yrNum] for( moNum in 1:length(months) ) { mo &lt;- months[moNum] cat(yr,mo,"\n") plot(newmap, xlim = c(110, 155), ylim = c(-35, -20), asp = 1) mtext( paste(yr,"month",mo), cex=0.7) #add titile to subplot pMoYr &lt;- p1[ p1$year==yr &amp; p1$month==mo, ] points(pMoYr$lon, pMoYr$lat, col = "red", cex = 3) } } mtext("rworldmap layout demo",outer=TRUE,line=-2) par(oldPar) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload