mplot3d 工具包#

使用 mplot3d 工具包生成 3D 图形.

本教程展示了各种 3D 图形.单击图形以查看每个完整的图库示例以及生成图形的代码.

3D 坐标轴(类 Axes3D )通过将关键字参数 projection="3d" 传递给 Figure.add_subplot 来创建:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

与 2D 子图一样,可以在同一图形上添加多个 3D 子图.

../../../_images/sphx_glr_subplot3d_001.png

在 3.2.0 版本发生变更: 在 Matplotlib 3.2.0 之前,需要显式导入 mpl_toolkits.mplot3d 模块,才能使 '3d' 投影到 Figure.add_subplot .

有关 mplot3d 工具包的更多信息,请参见 toolkit_mplot3d-faq .

折线图#

参见 Axes3D.plot 的 API 文档.

../../../_images/sphx_glr_lines3d_001.png

散点图#

参见 Axes3D.scatter 的 API 文档.

../../../_images/sphx_glr_scatter3d_001.png

线框图#

参见 Axes3D.plot_wireframe 的 API 文档.

../../../_images/sphx_glr_wire3d_001.png

表面图#

参见 Axes3D.plot_surface 的 API 文档.

../../../_images/sphx_glr_surface3d_001.png

Tri-Surface 图#

参见 Axes3D.plot_trisurf 的 API 文档.

../../../_images/sphx_glr_trisurf3d_001.png

等高线图#

参见 Axes3D.contour 的 API 文档.

../../../_images/sphx_glr_contour3d_001.png

填充等高线图#

参见 Axes3D.contourf 的 API 文档.

../../../_images/sphx_glr_contourf3d_001.png

在 1.1.0 版本加入: 第二个 contourf3d 示例中演示的功能是作为 1.1.0 版本的错误修复的结果而启用的.

填充 3D 线之间#

参见 Axes3D.fill_between 的 API 文档.

../../../_images/sphx_glr_fillbetween3d_001.png

在 3.10 版本加入.

多边形图#

参见 Axes3D.add_collection3d 的 API 文档.

../../../_images/sphx_glr_polys3d_001.png

条形图#

参见 Axes3D.bar 的 API 文档.

../../../_images/sphx_glr_bars3d_001.png

Quiver#

参见 Axes3D.quiver 的 API 文档.

../../../_images/sphx_glr_quiver3d_001.png

3D 中的 2D 图#

../../../_images/sphx_glr_2dcollections3d_001.png

文本#

参见 Axes3D.text 的 API 文档.

../../../_images/sphx_glr_text3d_001.png