Re: [R] Add ellipse to plot

From: Alberto Monteiro <albmont_at_centroin.com.br>
Date: Mon 09 Oct 2006 - 19:52:34 GMT

Kamila Naxerova wrote:
>
> Is there a way to plot elliptical shapes? symbols()
> only provides circles...
>
Elipse centered at (x0, y0) with axes _a_ and _b_:

theta <- seq(0, 2 * pi, length=(big enough)) x <- x0 + a * cos(theta)
y <- y0 + b * sin(theta)
plot(x, y, type = "l")

:-)

Or, if you want to rotate it alpha degrees from the x-axis:

x <- x0 + a * cos(theta) * cos(alpha) - b * sin(theta) * sin(alpha) y <- y0 + a * cos(theta) * sin(alpha) + b * sin(theta) * cos(alpha)

Of course, the above formulas can be rewritten without the products of trig functions, but this way it's obvious what it's doing.

Alberto Monteiro



R-help@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. Received on Tue Oct 10 05:54:01 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 09 Oct 2006 - 20:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.