使用Python,是否可以在 x 和 y 中绘制隐式方程式?
例如,
x³y²+ 3 x y + 9 x +x⁴y⁴+x⁴+ 3 = 0
或者使用类似Python的符号
x**3*y**2 + 3*x*y + 9*x + x**4*y**4 + 3 = 0
答案 0 :(得分:0)
您可以使用外部库绘制隐式函数
SymPy,即使用
sympy.plot_implicit
依次使用Matplotlib
引擎盖:
from sympy import symbols, plot_implicit
x, y = symbols('x y')
plot_implicit(x**3*y**2+3*x*y+9*x+x**4*y**4+x**4+3, x, y)
另一种方法(比SymPy的使用少直接)是扩展Matplotlib中plt.contour
的使用
In [1]: import matplotlib.pyplot as plt
...: import numpy as np
...:
...: %matplotlib
...:
...: X = np.linspace(-4, 4, 201)
...:
...: x, y = np.meshgrid(X, X)
In [2]: z = x**3*y**2+3*x*y+9*x+x**4*y**4+x**4+3
In [3]: plt.contour(x, y, z, (0,))
Out[3]: <matplotlib.contour.QuadContourSet at 0x7fb866c805d0>
(请注意(0,)
是一个包含要为其绘制等值线的所有值的元组)