[R] filled maps

antonio rodriguez arv at ono.com
Tue Feb 3 11:28:13 CET 2004


Hi,

Some time ago, Roger Peng posted this solution, which I found very useful:

junk.mat <- matrix(rnorm(1600), 16, 100)
contour.mat <- ifelse(junk.mat < 2, 0, junk.mat)
filled.contour(junk.mat, color = terrain.colors, 
               plot.axes = contour(contour.mat, levels = 1, 
                                   drawlabels = FALSE, axes = FALSE, 
                                   frame.plot = FFALSE, add = TRUE))

The 'plot.axes' argument to filled.contour() gives you access to the
coordinate system in the actual plotting area.  However, you will notice
that the axes are missing.  You need to add them explicitly, as in:

filled.contour(junk.mat, color = terrain.colors, 
               plot.axes = { contour(contour.mat, levels = 1, 
                                     drawlabels = FALSE, axes = FALSE, 
                                     frame.plot = FFALSE, add = TRUE);
			     axis(1); axis(2) } )


Cheers,

Antonio

> -----Mensaje original-----
> De: r-help-bounces+arv=ono.com at stat.math.ethz.ch
> [mailto:r-help-bounces+arv=ono.com at stat.math.ethz.ch]En nombre de Janus
> Larsen
> Enviado el: martes, 03 de febrero de 2004 9:36
> Para: R-help at stat.math.ethz.ch
> Asunto: [R] filled maps
> 
> 
> Hi R-Help,
> 
> I would like to make filled contour maps of ocean data overlaid by
> costlines from the map package.
> I can draw the filled contours and the coastlines om the same plot, but
> the filled contour also covers part of the land. To get rid of that I
> tried to draw a filled coastline map on top of the filled contour, but
> the filled map only draws the closed contours - so most of the land is
> missing.
> Example:
> map("worldHires",xlim=c(0,15),ylim=c(50,60)) #Draw relevant region
> (North Sea and Denmark waters)
> map("worldHires",xlim=c(0,15),ylim=c(50,60),fill=TRUE) # This only draws
> Denmark and Holland (Sweden, uk, Germany etc. disappears because they
> are not closed polygons).
> 
> Any hint on how to fix this problem or a different approach is most
> welcome.
> Janus
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
---
Incoming mail is certified Virus Free.



---




More information about the R-help mailing list