From: Caroline Houldcroft <c.j.houldcroft at swansea.ac.uk>
Date: 01 Dec 2004 15:16:55 +0000
> I would like to create a filled.contour plot with colour bar and overlay
> a map.
>
> I need to create several of these representing variables with different
> spatial extents for comparison. When I try to fix the plot area size and
> axes limits as follows:
>
> par(fig=c(0,1.0,0.3125,1.0)
>
> filled.contour(x=seq((320/2)-180.5,(480/2)-180.5,len=nrow(oct94)),
> y=seq((190/2)-90.5,(240/2)-90.5,len=ncol(oct94)),
> z=as.matrix(oct94),
> color=heat.colors,
> levels=seq(0,30,2),
> plot.axes={axis(1,seq(-60,60,by=20));
> axis(2,seq(5,30,by=5))})
>
>
> my definitions were ignored producing a stretched image of the area with
> limits defined by the contour plot.
>
I cannot answer this part of the question because your example is not
reproducible (Error in nrow(oct94) : Object "oct94" not found) [and
the
first line contains a syntax error.]>
> I have also had difficulties overlaying a map on the same axes. The
> following example, taken from the r-help archives, gave the error
> "couldn't find function "world""
>
> library(maps)
> filled.contour(x=seq((320/2)-180.5,(480/2)-180.5,len=nrow(oct94)),
> y=seq((190/2)-90.5,(240/2)-90.5,len=ncol(oct94)),
> z=as.matrix(oct94),
> color=heat.colors,
> levels=seq(0,30,2),
> plot.axes={world(ylim=c(5,30),xlim=c(-30,50),add=T);
> axis(1);axis(2)})
>
The world() function is not part of the maps package, it is in the
fields package. If you want to use the maps package, try:
map("world", ylim=c(5,30), xlim=c(-30, 50), add=T)
Hope this helps,
Ray Brownrigg