def plot_surface(x,y,z): fig, ax = plt.subplots(figsize = (12,7),subplot_kw={"projection": "3d"}) norm = mpl.colors.Normalize(vmin=-1, vmax=1) # 绘图主程序 surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=plt.cm.coolwarm,norm = norm,linewidth=0.5, antialia...
The surface is made opaque by using antialiased=False. Also demonstrates using the LinearLocator and custom formatting for the z axis tick labels. ''' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, ...
surf = ax.plot_surface(X,Y,Z,cmap=cm.coolwarm,linewidth=0,antialiased=False) # Customize the z axis ax.set_zlim(-1.01,1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) #Add a colcr bar which maps values to colors fig.co...
s1 = ax.plot_surface(X, Y, Z(X, Y), rstride=10, cstride=10, cmap=cm.jet, linewidth=1, antialiased=True) #绘制面 ax.set_xlim3d(0,50) #指定x轴坐标值范围 ax.set_ylim3d(0,50) #指定y轴坐标值范围 ax.set_zlim3d(0,50) #指定z轴坐标值范围 fig.colorbar(s1,shrink=1,aspect=5)...
plt.title('A simple plot')plt.show() 添加图例 plt.figure(figsize=(8,6)) plt.plot(y[:,0],lw=1.5,label='1st') plt.plot(y[:,1],lw=1.5,label='2st') plt.plot(y,'ro') plt.grid(True) plt.axis('tight') plt.xlabel('index') ...
# Plot the surface. surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0, antialiased=False) # Customize the z axis. ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # Add a color bar wh...
(X**2+Y**2))fig=plt.figure()ax=fig.add_subplot(111,projection='3d')surf=ax.plot_surface(X,Y,Z,cmap='viridis',linewidth=0.5,antialiased=False)ax.set_title('3D Surface with Custom Grid - how2matplotlib.com')ax.set_xlabel('X axis')ax.set_ylabel('Y axis')ax.set_zlabel('Z ...
plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0, antialiased=False) # Customize the z axis. ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # Add a color bar which maps values to colors. fig....
plot_surface(X, Y, -phi, rstride=2, cstride=2, color='r', linewidth=0, alpha=0.6, antialiased=True) ax1.contour(X, Y, phi, 0, colors='g', linewidths=2) show_fig1() fig2 = plt.figure(2) def show_fig2(): contours = measure.find_contours(phi, 0) ax2 = fig2.add_...
ax.plot_surface(x, y, z, cmap='viridis') 6、添加交互功能 为了使三维图像可转动,我们需要添加一些交互功能,我们可以使用mpl_toolkits中的NavigationToolbar2类来实现这一点。 from mpl_toolkits.mplot3d import NavigationToolbar2 toolbar = NavigationToolbar2(fig, plt) ...