From paul@stat.auckland.ac.nz  Tue Feb 27 22:13:09 2001
From: paul@stat.auckland.ac.nz (Paul Murrell)
Date: Wed, 28 Feb 2001 11:13:09 +1300
Subject: [Rd] Plotting points on a filled.contour plot (PR#857)
References: <200102270900.KAA23881@pubhealth.ku.dk>
Message-ID: <003501c0a10a$77f7b040$175dd882@stat.auckland.ac.nz>

Hi


> When adding points to a filled.contour plot they do not appear at the
correct
> coordinates.
> The following code demonstrates this.
>
> a<-expand.grid(1:20,1:20)
> b<-matrix(a[,1]+a[,2],20)
> filled.contour(x=1:20,y=1:20,z=b)
> points(10,10)


The problem here is that filled.contour is actually a combination of two
plots;  one is the filled contour and one is the legend.  filled.contour
sets up two separate coordinate systems for these two plots, but only does
so internally - once the function has returned these coordinate systems are
lost.  In order to access the coordinate system of the main contour plot you
can specify graphics commands in the plot.axes argument.  For example, in
your case, replace your call to filled.contour with the following, and all
is as it should be ...

filled.contour(x=1:20,y=1:20,z=b,plot.axes={axis(1);axis(2);points(10,10)})

Paul


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Plotting points on a filled.contour plot (PR#857)
Paul Murrell