plot_trisurf(x, y, z, linewidth=0.2, antialiased=True) plt.show() # 3D线图 line_3d() # 3D散点图 scatter_3d() # 3D随机颜色散点图 scatter_random_color_3d() # 线框图 wireframe_3d() # 曲面图,默认情况下,它将以纯色的阴影着色,但它也通过提供 cmap 参数支持颜色映射。 surface_3d() ...
importmatplotlib.pyplotaspltfrommpl_toolkits.mplot3dimportAxes3Dfig=plt.figure()ax=fig.add_subplot(111,projection='3d')x=[1,2,3,4,5]y=[2,3,4,5,6]z=[3,4,5,6,7]ax.plot(x,y,z)ax.set_xlabel('X data')ax.set_ylabel('Y data')ax.set_zlabel('Z data')ax.set_title('3D Li...
ax.plot3D(x, y, z,'gray') ax.set_title('3D line plot') plt.show() 输出结果如下所示: 上述代码中的 ax.plot3D() 函数可以绘制各种三维图形,这些三维图都要根据(x,y,z)三元组类来创建。 02、3D散点图 通过ax.scatter3D() 函数可以绘制 3D 散点图,示例代码如下: from mpl_toolkits import m...
matplotlib中提供3D画图库为mplot3d,在使用时,我们通过一个关键字projection="3d"即可创建3D坐标轴。具体代码如下: 代码语言:javascript 代码运行次数:0 复制 Cloud Studio代码运行 from mpl_toolkitsimportmplot3dimportnumpyasnpimportmatplotlib.pyplotasplt fig=plt.figure() ax=plt.axes(projection=“3d”) plt.s...
[<mpl_toolkits.mplot3d.art3d.Line3D at 0x1f0ee3b35d0>]4. 三维散点图 fig = plt.figure(figsize=(5, 3))axes = Axes3D(fig, auto_add_to_figure=False)fig.add_axes(axes)# 画散点图x = np.random.rand(50)y = np.random.rand(50)z = np.random.rand(50)axes.scatter(x, y, z, ...
importmatplotlib.pyplotaspltfrommpl_toolkits.mplot3dimportAxes3Dimportnumpyasnp fig=plt.figure()ax=fig.add_subplot(111,projection='3d')t=np.linspace(0,2*np.pi,100)x=np.sin(t)y=np.cos(t)z=t ax.plot(x,y,z)ax.set_title("3D Line Plot - how2matplotlib.com")plt.show() ...
3,'go-.')# green dashed lineplt.show() 点线的设置 三种设置方式 对实例使用一系列的setter方法 x = np.arange(0,10) y = np.random.randint(10,30,size =10) line,= plt.plot(x, y) line2 = plt.plot(x,y*2,x,y*3) line.set_linewidth(5) ...
ax = plt.axes(projection='3d') # 三维螺旋线的数据 zline = np.linspace(0, 15, 1000) xline = np.sin(zline) yline = np.cos(zline) ax.plot3D(xline, yline, zline, 'gray') # 三维散点的数据 zdata = 15 * np.random.random(100) ...
from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') 1. 2. 3. 4. 5. 你可能会看到有的教程写的是ax = Axes3D(fig),这是version1.0.0之前的写法 三维绘图函数 LinePlot Axes3D.``plot(xs,ys, *args,zdir=‘z’, **kwargs) ...
api里面的例子比较复杂,本人自己写了一个例子绘制一条三维动态曲线 1#外部获得数据2myCurve = np.fromfile('data.bin', dtype=np.float).reshape(-1,3)3xLength,j =myCurve.shape4fig =plt.figure()5ax1=plt.axes(projection='3d')6#初始化绘制7line, = ax1.plot([],[],[],animated=True)8#定义...