问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/6870472/how-to-plot-2-variables-on-a-plane