I want to draw ellipses, hyperbolas in R.
How can I do it using ggplot2?
Let me give an example
x^2 +3xy+ 4x+ 2y+ 2y^2 = 0
for
x between -2 and 2
y between -2 and 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Construct a data field:
Make a basic
geom_contourplot with each level coloured differently:Now get rid of the lines for all but the “0” level. This depends on
stat_contourpicking zero as one of its contour levels, which might be fragile under some circumstances … (It’s not obvious to me thatstat_contour()allows control of what levels are chosen, equivalent to thelevelsargument tocontour()orcontourLines()in base R — if it did, this process would be a little bit easier. One might submit a wishlist item to https://github.com/hadley/ggplot2/issues , if one cared enough about this …)