如何在平面上绘制 2 个变量 [英] How to plot 2 variables on a plane
本文介绍了如何在平面上绘制 2 个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个等式:
x**2 + y**2 - 4 = 0
如何使用 sympy、matplotplib 或其他 Python 解决方案查看圆圈?
我知道我可以
from sympy import Plot
from sympy import Symbol
x = Symbol('x')
y = Symbol('y')
Plot(x**2 + y**2 - 4)
但后来我得到 z = x**2 + y**2 - 4
,一个 3D 图形而不是平面交点.我知道可能需要解方程.
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.
推荐答案
是的 KillianDS,我现在明白这是重复的 是否可以使用 Matplotlib 绘制隐式方程?
Yes KillianDS, I now understand this is a duplicate of Is it possible to plot implicit equations using Matplotlib?
虽然我仍然不知道如何在 sympy 中做到这一点.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.
这篇关于如何在平面上绘制 2 个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文