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...
plt.plot(x,sin_y)# 默认第一条曲线颜色为蓝色,第二条为橘色 plt.plot(x,cos_y)# 保存图片 plt.savefig('正弦余弦曲线图.jpg')# 显示绘制的图片 plt.show() 运行效果如下: 上面的示例可以看到,调用两次plot函数,会将sin和cos曲线绘制到同一个二维坐标系中,如果想绘制到两张画布中,可以调用subplot()函数...
3. 三维折线图 fig = plt.figure(figsize=(5, 3))x = np.linspace(0, 100, 400)y = np.sin(x)z = np.cos(x)# 三维折线图axes = Axes3D(fig, auto_add_to_figure=False)fig.add_axes(axes)axes.plot(x, y, z)[<mpl_toolkits.mplot3d.art3d.Line3D at 0x1f0ee3b35d0>]4. 三维散点...
https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.art3d.Line3DCollection.html#mpl_toolkits.mplot3d.art3d.Line3DCollection importmatplotlib.pyplotasplt;importmatplotlibasmltfrommpl_toolkits.mplot3dimportaxes3dimportnumpyasnp mlt.use('TkAgg');plt.figure(1);ax=plt.subplot(111,projecti...
ax.plot(x,y,z)ax.set_title("3D Line Plot - how2matplotlib.com")plt.show() Python Copy Output: 3. 三维曲面图 三维曲面图可以用来展示三维空间中的曲面,是研究复杂曲面形态的有力工具。 示例代码 3:绘制三维曲面图 importmatplotlib.pyplotaspltfrommpl_toolkits.mplot3dimportAxes3Dimportnumpyasnp ...
1. 3D线框图(3D Line Plot) 3d绘图类型(1):线框图(Wireframe Plot)_QomolangmaH的博客-CSDN博客编辑https://blog.csdn.net/m0_63834988/article/details/132890293?spm=1001.2014.3001.5501编辑https://blog.csdn.net/m0_63834988/article/details/132890293?spm=1001.2014.3001.5501 https://blog.csdn...
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) ...
最后调用plot3D() 方法绘制 3d 图形,代码如下: #调用 ax.plot3D创建三维线图ax.plot3D(x,y,z,'gray')ax.set_title('3D line plot')plt.show() 完整程序如下所示: from mpl_toolkits import mplot3d import numpy as np import matplotlib.pyplot as plt ...
fig = plt.figure(figsize=(5, 3)) x = np.linspace(0, 100, 400) y = np.sin(x) z = np.cos(x) # 三维折线图 axes = Axes3D(fig, auto_add_to_figure=False) fig.add_axes(axes) axes.plot(x, y, z) [<mpl_toolkits.mplot3d.art3d.Line3D at 0x1f0ee3b35d0>] 4. 三维散点图...
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) ...