是否可以使用Matplotlib绘制隐式方程式? [英] Is it possible to plot implicit equations using Matplotlib?

查看:99
本文介绍了是否可以使用Matplotlib绘制隐式方程式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Matplotlib中绘制隐式方程式(形式为f(x,y)= g(x,y),例如X ^ y = y ^ x).这可能吗?

I would like to plot implicit equations (of the form f(x, y)=g(x, y) eg. X^y=y^x) in Matplotlib. Is this possible?

推荐答案

我不认为对此有很好的支持,但是您可以尝试类似的

I don't believe there's very good support for this, but you could try something like

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

delta = 0.025
xrange = arange(-5.0, 20.0, delta)
yrange = arange(-5.0, 20.0, delta)
X, Y = meshgrid(xrange,yrange)

# F is one side of the equation, G is the other
F = Y**X
G = X**Y

matplotlib.pyplot.contour(X, Y, (F - G), [0])
matplotlib.pyplot.show()

请参见API文档对于contour:如果第四个参数是一个序列,则它指定要绘制的轮廓线.但是该图将仅与您的范围的分辨率一样好,并且某些功能可能永远无法正确显示,通常是在自相交点.

See the API docs for contour: if the fourth argument is a sequence then it specifies which contour lines to plot. But the plot will only be as good as the resolution of your ranges, and there are certain features it may never get right, often at self-intersection points.

这篇关于是否可以使用Matplotlib绘制隐式方程式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆