如何将字符串添加到 Axes3D 中的轴而不是数字?
我刚开始使用 matplotlib。我使用 Axes3dD 绘制类似于他们网站上给出的示例(http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html)。请注意,必须使用最后一个版本(matplotlib 0.99.1),否则轴会有点怪异。该示例使用以下代码:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
ys = np.random.rand(20)
ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
现在我的问题是,我无法将轴重命名为我想要的。我需要将订书钉命名为字符串名称,而不是数字。这我只想在两个维度上做——x 维度和 z 维度(深度)。我试过使用这个命令:
ax.set_xticklabels('First staple',(0,0))
我没有收到错误消息,但仍然没有刺痛。如果有人能回答这个问题,我将非常高兴!