colorbar units don't appear in figure (matplotlib)
<p>Im trying to do the following figure, but the units below the colorbar do not appear. The units only appear when I make the width and the height of the figure extremely large.</p>

<p>This is the code I use for inserting a customized colorbar:</p>

<pre><code>from mpl_toolkits.axes_grid.axes_grid import AxesGrid
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
def add_at(ax, t, loc=1):
    fp = dict(size=16, weight='bold')
    _at = AnchoredText(t, loc=loc, prop=fp)
    ax.add_artist(_at)
return _at
</code></pre>

<p>now I make the figure</p>

<pre><code>fig = plt.figure(figsize = (12, 5))
axs1 = plt.subplot2grid((2,2), (0,0))

im = m.contourf(x, y, var,levels=np.arange(vmin, vmax, delta))
</code></pre>

<p>and finally I  add the colorbar </p>

<pre><code>cax = fig.add_axes([0.42, 0.05, 0.25, 0.03]) 
cbar = fig.colorbar(im, cax, orientation='horizontal')
cbar.ax.tick_params(labelsize=12) 
cbar.set_label('units', size=16, weight='bold')
</code></pre>

<p>finally I save the figure</p>

<pre><code>fig.savefig('name.png', dpi=300)
</code></pre>

<p>But I see this the figure with the colorbar but the units dont appear for lack of space. I tried adjusting the width and height of the figure, but it doesnt work unless I do a huge figure but then the spacing between sublpots is wrong.</p>

<p>this is the figure:</p>

<p><img src="http://i.stack.imgur.com/4JEQu.png" alt="link"></p>

<p><code>set_xticklabels</code> might help. Check this:
<a href="http://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html" rel="nofollow">http://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html</a></p>

python matplotlib