# aaa2.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
xlist = np.linspace(-1.0,1.0, 100)
ylist = np.linspace(-1.0,1.0,100)
X,Y = np.meshgrid(xlist, ylist)
Z = X**4 - X**2 + Y**2
# 绘制轮廓图
fig,ax = plt.subplots(1,1)
cp = ax.contourf(X,Y,Z,10) # 10表示轮廓的个数
fig.colorbar(cp)
ax.set_title("Filled Countors Plot")
ax.set_ylabel('y(cm)')
plt.show()
# 绘制三维图形
fig2 = plt.figure()
ax = Axes3D(fig2)
ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap='rainbow')
plt.show()