python - matplotlib 中轴的标签被刻度覆盖

标签 python matplotlib

如何更改图形的 z 轴标签位置。这就是我的身材。 enter image description here

这是我的代码:

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10,8))
ax = fig.gca(projection='3d') # get current axis        
surf = ax.plot_surface(X, Y, Z)
ax.set_xlabel('Intercept')
ax.set_ylabel('Slope')
ax.set_zlabel('Error')

最佳答案

您可以使用labelpad参数:

plt.zlabel(*, labelpad=20)

或者您可以稍后更改它:

ax.zaxis.labelpad = 20

不断尝试直到它满足您的需求。

关于python - matplotlib 中轴的标签被刻度覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36448733/

相关文章:

python - FixedFormatter_shoul_only_be_used_together_with_FixedLocator : How to deal with this warning in matplotlib?

python - Matplotlib 用标记而不是箭头进行注释

python - 为什么 SendGrid 允许我从任何地址发送电子邮件?

python - 临时更改 pandas 的 set_option 以显示数据框

python - 使用 Tweepy 将推文插入 MySQL DB

python - 使用 Python 和 Matplotlib 将立体图像和深度图转换为 3D 散点图

python - 在 C++ 中运行 python 对象

python - 找出两个(不谐波)波之间的相位差

python - 如何从列表中绘制多个图例

python - 防止 seaborn 箱线图中的科学记数法