将x轴与条Matplotlib对齐

时间:2019-06-11 17:36:34

标签: python matplotlib

我是matplotlib的新手。我试图制作一个简单的条形图,但是似乎无法使轴与条形图对齐。我尝试了多种宽度组合,但是我确定我遗漏了一些东西。

labels, values = zip(*charfarm.items())
indexes = np.arange(len(labels))
width = 0.8
plt.bar(indexes, values, width)
plt.xticks(indexes + width, labels)
plt.show()

Graph

1 个答案:

答案 0 :(得分:1)

由于您在#There is no deemphasize, having which saves a considerable amount of time. 函数中进行了indexes + width操作,因此您的价格变动被抵消了。

请参考以下代码:

plt.xticks

enter image description here