pyplot如何绘制难以简化为y=f(x)的函数

2024-04-19 12:35:40 发布

您现在位置:Python中文网/ 问答频道 /正文

例如,如何绘制sin(x^2 + y^2) = cos(x * y)
很难将此函数简化为y = f(x)。你知道吗

我认为这不是对Is it possible to plot implicit equations using Matplotlib?的重复,因为我的问题是关于y = f(x)而不是z = f(x, y)


Tags: to函数plotmatplotlibis绘制itsin
1条回答
网友
1楼 · 发布于 2024-04-19 12:35:40

轮廓函数可用于:

import numpy as np
import matplotlib.pylab as plt

x = np.linspace(-1., 1.)
y = np.linspace(-1., 1.)[:, None] # y has to be 2d array
plt.contour(x, y.flatten(), np.sin(x*x+y*y) - np.cos(x*y))

plt.show()

enter image description here

相关问题 更多 >