contour 与 contourf api
https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.contourf.html
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# 计算x,y坐标对应的高度值
def f(x, y):
return (1-x/2+x**3+y**5) * np.exp(-x**2-y**2)
# 生成x,y的数据
n = 256
x = np.linspace(-3, 3, n)
y = np.linspace(-3, 3, n)
# 把x,y数据生成mesh网格状的数据,因为等高线的显示是在网格的基础上添加上高度值
X, Y = np.meshgrid(x, y)
# 填充等高线
plt.contour(X, Y, f(X, Y))
# 显示图表
plt.show()
#result
参考
https://blog.csdn.net/lens___/article/details/83960810