区分 Matplotlib 中的正交投影和透视投影
matplotlibpythondata visualization更新于 2025/6/3 9:48:17
要绘制透视和正交投影图,我们可以采取以下步骤 −
- 设置图形大小并调整子图之间和周围的填充。
- 创建新图形或激活现有图形。
- 将 '~.axes.Axes' 添加到图形作为子图布置的一部分。
- 在 ax1 轴上将投影类型设置为 '透视'。
- 设置图的标题。
- 添加 '~.axes.Axes'作为子图布置的一部分添加到图形中。
- 将投影类型设置为"正交"在 ax2 轴上。
- 设置图的标题。
- 要显示图形,请使用 show() 方法。
示例
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1, projecting='3d')
ax1.set_proj_type('persp')
ax1.set_title('Perspective')
ax2 = fig.add_subplot(1, 2, 2,投影='3d')
ax2.set_proj_type('ortho')
ax2.set_title('Orthographic')
plt.show()
输出

相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

