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?
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]]
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.
You just have to RTFM!
?filled.contour tells you you cannot add points (or lines) to a finished plot,
and tells
you how to do what you want.
So, based on your most recent offline message, try:
filled.contour(x, y, mslp, zlim = c(1000,1020),
color.palette = colorRampPalette(c("blue", "lightblue",
"yellow", "orange", "red")),
xlab = "Longitude (?)", ylab = "Latitude (?)",
xlim = c(-5, 40), ylim = c(35, 70), nlevels = 25,
plot.axes = {axis(1); axis(2); ### this is the key part
map('worldHires', xlim = c(-5, 40), ylim = c(35, 70), add = T, col =
"darkgrey")}
)
Ray Brownrigg
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?
>
> 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.