调整 Matplotlib 中 3D 图的轴标签和名称方向
matplotlibpythondata visualization更新于 2025/7/6 5:00:17
要调整 matplotlib 中 3D 图的轴标签和名称方向,我们可以采取以下步骤 −
- 设置图形大小并调整子图之间和周围的填充。
- 使用 facecolor=white 创建新图形或激活现有图形。
- 获取具有 3D 投影的当前图形。
- 使用 linespacing 设置 X、Y 和 Z 轴标签。
- 使用 plot() 方法绘制数据点。
- 设置轴距。
- 要显示图形,请使用 show() 方法。
示例
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
figure = plt.figure(facecolor='w')
ax = figure.gca(projection='3d')
xLabel = ax.set_xlabel('X-axis', linespacing=3.2)
yLabel = ax.set_ylabel('Y-axis', linespacing=3.1)
zLabel = ax.set_zlabel('Z-Axis', linespacing=3.4)
plot = ax.plot([1, 2, 3], [1, 2, 3])
ax.dist = 10
plt.show()
输出

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

