[R] Draw a circle on a filled.contour() plot
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Dec 17 13:32:43 CET 2006
On 12/17/2006 7:06 AM, Webmaster wrote:
> Hi all,
>
> I'm trying to use symbols() to draw a circle of a given radius at a
> given position onto a filled.contour() plot. The commands I issue are:
>
>> filled.contour(y,x,z,levels=seq
>> (0.02,1.0,len=50),color.palette=colorRampPalette(c
>> ("blue","yellow","red")),title=title(main="",xlab="",ylab=""))
>> symbols(0.62,0.0,circles=c(2.5),add=TRUE,inches=FALSE
>
> As can be seen on the resulting PDF file (http://www.eleves.ens.fr/
> home/coudert/hist_2d.pdf), the circle appears to have the right
> radius but its center is not the correct one [0.62, 0]. What am I
> missing here?
There's a note on the man page about this:
The output produced by 'filled.contour' is actually a combination
of two plots; one is the filled contour and one is the legend.
Two separate coordinate systems are set up for these two plots,
but they are only used internally - once the function has returned
these coordinate systems are lost. If you want to annotate the
main contour plot, for example to add points, you can specify
graphics commands in the 'plot.axes' argument. An example is
given below.
Duncan Murdoch
>
> Thanks for your help,
> FX
>
> PS: complete input (5 lines), data file for the contour plot and PDF
> result on my system can be found at:
> Data file: http://www.eleves.ens.fr/home/coudert/hist_2d
> R script: http://www.eleves.ens.fr/home/coudert/hist_2d.R
> PDF result: http://www.eleves.ens.fr/home/coudert/hist_2d.pdf
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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