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

Paul Murrell paul@stat.auckland.ac.nz
Wed, 28 Feb 2001 11:13:09 +1300


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._