<p>我想答案已经太迟了,不过也许这可以帮助其他人。在</p>
<p>在<em>mpld3</em>包中,将文本设置为刻度标签似乎确实存在一些问题,但是我能够做到这一点:将一些数据标绘到特定的范围值,然后将刻度设置为该范围,最后将刻度标签设置为所需的值。在</p>
<pre><code>from matplotlib import pyplot as plt
import numpy as np
import mpld3
fig, ax = plt.subplots()
feature_name = ('AccountLength','Intlact','Vmailact','Vmailnumber','day minutes','day calls','day charge','evening minutes','evening calls','evening charge','night minutes','night calls','night charge','intl minutes','intl calls','intl charge','cust calls')
importance = (0.0304,0.0835,0.0222,0.0301,0.1434,0.0315,0.1354,0.0677,0.0268,0.0669,0.0386,0.0286,0.0371,0.0417,0.0521,0.0434,0.1197)
ind = range(1, len(feature_name)+1)
width = 0.20
rects = ax.bar(ind, importance, width, color = 'r')
ax.grid(linestyle='solid')
ax.set_title("Why are my customers churning?", size=20)
ax.set_ylabel('Importance in percentage')
ax.set_xlabel('Feature Name')
ax.set_xticks(ind)
ax.set_xticklabels(feature_name)
mpld3.show()
</code></pre>
<p>结果:</p>
<p><a href="https://i.stack.imgur.com/1bgfS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1bgfS.jpg" alt="mpld3 ticklabels example"/></a></p>
<p>还有一个额外的人员要处理ticks循环(在<em>mpld3</em>中也不支持)。也许可以编写自定义插件来实现这一点。如果有人需要这个,我会更新答案。在</p>