1

Let's say I have an equation:

x**2 + y**2 - 4 = 0

How can I see the circle using sympy, matplotplib or another python solution?

I know in sympy I can

from sympy import Plot
from sympy import Symbol
x = Symbol('x')
y = Symbol('y')
Plot(x**2 + y**2 - 4)

But then I get z = x**2 + y**2 - 4, a 3D graph instead of the planar intersection. I understand there may be a need to solve the equation.

ubershmekel
  • 11,864
  • 10
  • 72
  • 89
  • 1
    possible duplicate of [Is it possible to plot implicit equations using Matplotlib?](http://stackoverflow.com/questions/2484527/is-it-possible-to-plot-implicit-equations-using-matplotlib) – KillianDS Jul 29 '11 at 08:36

1 Answers1

0

Yes KillianDS, I now understand this is a duplicate of Is it possible to plot implicit equations using Matplotlib?

Though I still don't know how to do it in sympy. The answer for matplotlib would be:

import matplotlib.pyplot
from numpy import arange
from numpy import meshgrid

delta = 0.025
xrange = arange(-3.0, 3.0, delta)
yrange = arange(-2.0, 2.0, delta)
X, Y = meshgrid(xrange,yrange)
F = X**2 + Y**2 -4
G = 0
matplotlib.pyplot.contour(X,Y,(F-G),[0])
matplotlib.pyplot.show()

I'm still having trouble, but I'll post it in a different question.

Community
  • 1
  • 1
ubershmekel
  • 11,864
  • 10
  • 72
  • 89