python - Z 标签未显示在 3d matplotlib 散点图中

标签 python matplotlib scatter3d

z 标签没有出现在我的图中。怎么了?

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
plt.show()

Output

ax.set_zlabel("z")ax.set(zlabel="z") 都不起作用。 x 和 y 标签工作正常。

最佳答案

这是一个填充问题。

labelpadfloat The distance between the axis label and the tick labels. Defaults to rcParams["axes.labelpad"] (default: 4.0) = 4.

您可以使用matplotlib.axis.ZAxis.labelpad调整 z 轴的值:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("StackOverflow", rotation=90)
ax.zaxis.labelpad=-0.7 # <- change the value here
plt.show();

输出:

enter image description here

关于python - Z 标签未显示在 3d matplotlib 散点图中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75275130/

相关文章:

user-interface - 是否有标准方法来选择图中轴的刻度位置?

matlab - 如何使用matlab在3D大数据散点图中用不同颜色标记一个点(我有x,y,z)?

python - 将 tf.Tensor 转换为 numpy 数组,然后将其另存为图像而不需要eager_execution

python - 所需的分发版本(>=0.6.49)不可用?

python - 如何解析并附加到 flexget yaml 配置文件?

python - 使 Matplotlib map 绘图相互对齐

python-ldap 在 Heroku 中安装失败

python - 如何用另一个函数装饰 matplotlib 图

matlab - scatter3 的问题

r - 使用 scatter3D() (plot3D 包)在 R 中绘制多元线性回归