[R] plot filled.contour over continent map

Greg Snow Greg.Snow at imail.org
Thu Nov 19 20:21:49 CET 2009


You probably want to put the map boundaries on top of the contour plot rather than the other way around.  Here is one example of doing that (find the correct asp may be the hardest part):

library(maps)

x <- seq( -124.7, -67, length.out=25 )
y <- seq( 25, 49, length.out=25 )

z <- outer(x,y,'+')

filled.contour(x,y,z, asp=1.5, plot.axes=map('state',add=TRUE)  )

hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Ray Brownrigg
> Sent: Thursday, November 19, 2009 11:50 AM
> To: r-help at r-project.org
> Cc: Matthias Demuzere
> Subject: Re: [R] plot filled.contour over continent map
> 
> On Fri, 20 Nov 2009, Matthias Demuzere wrote:
> > Dear all,
> >
> > As a newbie in R I would like to do the following (simple?) thing:
> >
> > to plot a filled.contour plot over a map showing country boundaries
> (e.g.
> > for Europe) What i do is:
> > map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary =
> TRUE,border=0.1)
> > map.axes()
> > filled.contour(mslp, zlim=c(1000,1020),color.palette =
> > colorRampPalette(c("blue", "white", "red")),main="Avegared MLSP (hPa)
> ERA40
> > JJA [1996-2002]", xlab="Longitude",ylab="Latitude")
> >
> > in which the mslp file is a netcdf file, with mean sea level pressure
> for a
> > range of lat/lon values.
> >
> > If I run the above-mentioned, I just get the map of Europe, without
> the
> > contourplot. When commenting the "map" statements I can see the
> > contourplot.
> >
> > So I am doing something wrong, but I really have no idea what?
> >
> Does the filled.contour() call work on its own? It should, right?
> 
> What I would expect to see is just the contour plot, since that should
> overwrite the map()
> plot.
> 
> Once you get filled.contour() working, try adding the map using:
> map('worldHires',xlim=c(-10,40),ylim=c(35,70),boundary = TRUE,
> border=0.1, add = TRUE)
> 
> You may have to put the xlim= and ylim= into the filled.contour() call
> to get what you
> want.
> 
> HTH
> Ray Brownrigg
> 
> > Anybody could help me out here?
> > Thanks in advance,
> >
> > Matthias
> >
> > -------------------------------------------------------------
> > Department of Earth & Environmental Sciences
> > Physical and Regional Geography Research Group
> > Regional climate studies
> >
> > Celestijnenlaan 200E
> > 3001 Heverlee (Leuven)
> > BELGIUM
> >
> > Tel: + 32 16 326424
> > Fax: + 32 16 322980
> >
> > http://geo.kuleuven.be/aow/
> > www.kuleuven.be/geography
> > -------------------------------------------------------------
> >
> >
> > 	[[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.
> 
> ______________________________________________
> 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