擅长:python、mysql、java
<p>使用:</p>
<pre><code># generate the data
n = 6
y = np.random.randint(low=0, high=10, size=n)
x = np.arange(n)
# generate the ticks and reverse it
xticks = range(n)
# xticks.reverse()
# plot the data
plt.figure()
ax = plt.subplot(111)
ax.bar(x, y)
# print xticks # prints [5, 4, 3, 2, 1, 0]
ax.set_xticklabels(xticks[::-1]) # <- Changed
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/mmD4D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mmD4D.png" alt="out"/></a></p>