<p>尝试以下操作:</p>
<p>事实证明,最棘手的部分是着色,但绘制线条和更新记号相对简单(参见代码末尾)</p>
<pre><code>import numpy as np
# get the RGBA values from your chosen colormap ('winter')
winter = matplotlib.cm.winter
winter = winter(range(winter.N))
# select N elements from winter depending on the number of columns in your
# dataframe (make sure they are spaced evenly from the colormap so they are as
# distinct as possible)
winter = winter[np.linspace(0,len(winter)-1,auction.shape[1],dtype=int)]
# set the alpha value for the two rightmost columns
winter[1:,3] = 0.2 # 0.2 is a suggestion but feel free to play around with this value
new_winter = matplotlib.colors.ListedColormap(winter) # convert array back to a colormap
# plot with the new colormap
the_plot = auction[['OpenToLast','OpenToMaxHigh','OpenToMaxLow']].head(20).plot(kind='barh',
figsize=(7,10),
fontsize=10,
colormap = new_winter,
stacked = True,
legend = True)
the_plot.axvline(0,0,1) # vertical line at 0 on the x axis
start,end = the_plot.get_xlim() # find current span of the x axis
the_plot.xaxis.set_ticks(np.arange(start,end,10)) # reset the ticks on the x axis with increments of 10
</code></pre>
<p><a href="https://i.stack.imgur.com/EThZU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EThZU.png" alt="enter image description here"/></a></p>