擅长:python、mysql、java
<p>我没有意识到我可以在matplotlibapi中直接使用Pandas<code>plot</code>命令。现在,我复制了上面的代码,并进行了修改,以便在Matplotlib中添加其他元素。在</p>
<p>如果有人知道怎么做的话,最好在横条上加一个渐变,但是我会把这个问题标记为回答:</p>
<pre><code>import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
cols = ['OpenToLast','OpenToMaxHigh','OpenToMaxLow']
colors = {'OpenToLast':'b', 'OpenToMaxHigh' : '#b885ea', 'OpenToMaxLow': '#8587ea'}
axnum = auction[cols].head(20).plot(kind='barh',
figsize=(7,10),
fontsize=10,
color=[colors[i] for i in cols],
stacked = True,
legend = True)
axnum.xaxis.set_major_locator(ticker.MultipleLocator(10))
plt.axvline(0, color='b')
</code></pre>
<p><a href="https://i.stack.imgur.com/17twr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/17twr.jpg" alt="enter image description here"/></a></p>