[R] how to draw a circle

Gabor Csardi csardi at rmki.kfki.hu
Sat Apr 22 19:58:29 CEST 2006


Hmmm, could you explain this a bit? 
You want to add a circle to a plot? See the examples in help(symbols)

Or you want to calculate the coordinates of the points on a circle?

t <- seq(0,2*pi,length=100)
coords <- t(rbind( 10+sin(t)*2, 20+cos(t)*2))
plot(coords)

Here (10,20) is the center of the circle, and 2 is its radius.
If you set length to a bigger number you'll get smoother resolution.

A points (x,y) is inside the circle if (c1-x)^2+(c2-y)^2 < r^2
(c1, c2) is the center of the circle, r is its radius.

Gabor

On Sat, Apr 22, 2006 at 01:42:46PM -0400, Jian Zhang wrote:
> how to draw a circle (e.g. radius=10cm) of one point?
> And how to choose these points in the circle?
> Thanks!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK




More information about the R-help mailing list