【发布时间】:2011-04-25 01:14:52
【问题描述】:
我正在尝试在 matplotlib 条形图的 y 轴上的值之后添加 mi 或 km(英里、公里)。
现在我只是为 matplotlib 提供值,它会自动制作 yaxis 标签。我不知道如何将 mi 附加到值的末尾。
24 > 24 英里
ax.set_7ticklabels() 有一个选项,但是我需要静态设置它们。
【问题讨论】:
标签: python django graph charts matplotlib
我正在尝试在 matplotlib 条形图的 y 轴上的值之后添加 mi 或 km(英里、公里)。
现在我只是为 matplotlib 提供值,它会自动制作 yaxis 标签。我不知道如何将 mi 附加到值的末尾。
24 > 24 英里
ax.set_7ticklabels() 有一个选项,但是我需要静态设置它们。
【问题讨论】:
标签: python django graph charts matplotlib
你想要这样的东西吗?
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
x = range(10)
plt.plot(x)
plt.gca().xaxis.set_major_formatter(FormatStrFormatter('%d km'))
plt.show()
【讨论】: