擅长:python、mysql、java
<p><code>plt.colorbar()</code>是为非常简单的情况而制作的,例如,没有真正考虑具有2个y轴的绘图。
对于colorbar位置和属性的细粒度控制,您几乎应该始终使用colorbar指定要在哪个轴上打印colorbar。</p>
<pre><code># on the figure total in precent l b w , height
cbaxes = fig.add_axes([0.1, 0.1, 0.8, 0.05]) # setup colorbar axes.
# put the colorbar on new axes
cbar = fig.colorbar(mapable,cax=cbaxes,orientation='horizontal')
</code></pre>
<p>注意,colorbar使用以下关键字:</p>
<blockquote>
<p>keyword arguments:</p>
<p><em>cax</em>
None | axes object into which the colorbar will be drawn <em>ax</em>
None | parent axes object from which space for a new
colorbar axes will be stolen</p>
</blockquote>
<p>你也可以在这里看到我关于<a href="https://stackoverflow.com/questions/9912008/how-to-add-a-single-colobar-that-will-show-the-data-from-2-different-subplot/9914204#9914204">figure colorbar on separate axes</a>的更广泛的答案。</p>