fig = plt.figure() #建立图形窗口 ax = fig.gca( projection = '3d' ) #三维坐标系 Xc, Zc = np.meshgrid( np.arange(-1, 1, 0.005), np.arange(0, 1, 0.005 ) )#自变量网格坐标 Yc = Xc**2 ax.plot_surface( Xc, Yc, Zc, cstride = 1, rstride = 2, edgecolor = 'y' )#绘图 a...
fig = plt.figure() ax = fig.add_subplot(111, projection='3d') surface = ax.plot_surface(x, y, z, cmap='viridis') plt.show() 这段代码首先导入了Axes3D,它是Matplotlib中用于三维图形的工具。然后,创建了一个图形,并添加了一个三维坐标轴。plot_surface函数用来绘制三维曲面,其中cmap参数指定了色...
1)**2 - (Y - 1)** 2)#计算Z轴数据(高度数据)Z = (Z1 - Z2) * 2#绘制3D图形ax.plot_surface(X, Y, Z, rstride=1,#rstride(row)指定行的跨度cstride=1,#cstride(column)指定列的跨度cmap=plt.get_cmap('rainbow'))#设置颜色映射#设置Z轴范围ax.set_zlim(-2, 2)#设置标题plt.title("...
6. 3D向量场图(3D Vector Field Plot) 3d绘图类型(6)3D向量场图(3D Vector Field Plot)_QomolangmaH的博客-CSDN博客 https://blog.csdn.net/m0_63834988/article/details/132891976?spm=1001.2014.3001.5501 7. 3D表面投影图(3D Surface Projection Plot) 代码语言:javascript 代码运行次数:0 复制Cloud Studio 代...
mplot3d import axes3d ax = plt.axes(projection='3d') x = arange(-5, 5, 0.1) y = arange(-5, 5, 0.1) x,y = meshgrid(x, y) R = sqrt(x**2+y**2) z = sin(R) ax.plot_surface(x, y, z) ax.set_xlabel('X Axes') ax.set_ylabel('Y Axes') ax.set_zlabel('Z Axes'...
plot_surface(X,Y,f(X,Y),rstride=1,cstride=1,cmap=plt.cm.hot) '''旋转''' ax.view_init(elev=30,azim=125) '''显示''' plt.show() 3D条形图 import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt x = np.arange(8) y...
sub=fig.add_subplot(111,projection='3d')#3d表示三维图像 sub.plot_surface(x_mesh,y_mesh,z_mesh,color='blue') sub.set_xlabel(r'$x$') sub.set_ylabel(r'$y$') sub.set_zlabel(r'$z$') plt.show() 1. 2. 3. 4. 5. 6.
➤01 3D plot 1.基本语法 在安装matplotlib之后,自动安装有 mpl_toolkits.mplot3d。 #Importing Libraries import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d #3D Plotting fig = plt.figure() ax = plt.axes(projection="3d") ...
ax1 = fig.add_subplot(1, 2, 1, projection='3d') # 3D曲面图 ax2 = fig.add_subplot(1, 2, 2) # 等高线投影图 # 绘制3D曲面图 surf = ax1.plot_surface(x, y, z, cmap='viridis', edgecolor='none') ax1.set_xlabel('X axis') ...
➤03 绘制3D Surface (1) Ex1 ▲ 3D surface例子 #!/usr/local/bin/python# -*- coding: gbk -*-#***# TEST2.PY -- by Dr. ZhuoQing 2020-11-16## Note:#***fromheadmimport*frommpl_toolkits.mplot3dimportaxes3d ax=plt.axes(projection='3d')x=arange(-5,5,0.1)y=arange(-5,5,0.1...