[R-sig-Geo] Adding maps to a filled contour plot

antonio rodriguez arv at ono.com
Mon Oct 3 08:38:31 CEST 2005


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-sig-geo-bounces at stat.math.ethz.ch
> [mailto:r-sig-geo-bounces at stat.math.ethz.ch]En nombre de Anne Hertel
> Enviado el: jueves, 29 de septiembre de 2005 21:42
> Para: r-sig-geo at stat.math.ethz.ch
> Asunto: [R-sig-Geo] Adding maps to a filled contour plot
>
>
> Hi,
>
> I am trying to plot a filled contour map and overlay it with a
> map, but I'm having trouble with the map. The map is plotted, but
> it is stretched out over the color bar, and doesn't stay within
> the plotting area. If I just use the 'contour' function the 'map'
> function works fine, but I want the contours filled in.
>
> Here's the code:
> filled.contour(cor.enso.map,
> x=seq(-126.5625,-64.6875,,23),y=seq(23.720175,51.625732,,11),xlab=
> 'longitude',ylab='latitude')
> map(xlim=c(-127,-65),ylim=c(23,52),add=T)
>
> where cor.enso.map is a matrix of size [23,11].
>
> How do I make the map stay within the plotting area?
>
> Thanks,
> Anne Hertel
>
>
> ------------------------------------------------------------
> Anne M. K. Hertel
> Grad. Student & Research Assistant
> Department of Atmospheric Sciences
> University of Illinois at Urbana-Champaign
> Annex II, room 204
> Phone: (217) 333 6296
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.8/114 - Release Date: 28/09/2005
>
--




More information about the R-sig-Geo mailing list