1、contourf函数命令
cmap = matplotlib.cm.jet
norm = matplotlib.colors.Normalize(vmin=min(np.array(sol)), vmax=max(np.array(sol)))
plt.contourf(X,Y,Z,cmap=cmap,norm=norm,levels=50)
cbar = plt.colorbar()
plt.grid(False)
plt.show()
2、imshow函数命令
extent=(0,1,0,1)
cmap = matplotlib.cm.jet
norm = matplotlib.colors.Normalize(vmin=min(X), vmax=max(X))
fig = plt.figure(figsize=(10, 10))
ax= fig.add_subplot(131)
ax.imshow(z,extent=extent, origin='lower',cmap=cmap, norm=norm)
3、plot_surface函数命令-旋转-投影
X, Y = np.meshgrid(T.x, T.y)
Z=np.array(sol).reshape((T.n+1),(T.m+1))
plt.xlabel('x')
plt.ylabel('y')
cmap = matplotlib.cm.jet
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cmap)
ax.set_zlabel('$u_{h})$')
ax.set_title('The Plot ')
ax.set_xticks([0,0.5,1])
ax.set_yticks([0,0.5,1])
ax.view_init(90, 270)
ax.grid(False)
plt.show()
以上三种都能得到相同的结果-需要加以细节处理
how to rotate a 3D surface in matplotlib 网址: https://stackoverflow.com/questions/38326983/how-to-rotate-a-3d-surface-in-matplotlib
|