Use the same colorbar for different subplots in matplotlib
<p>I am plotting different figure in subplots using the following procedure.</p>

<pre><code>fig = figure(figsize=(10,11))
subplots_adjust(wspace=0.5,hspace=0.2)
iplot = 330
for i in range(9):
    iplot += 1
    ax = fig.add_subplot(iplot)
    ## Comparison Mreal - Real
    tmp = REAL[REAL.days==days[i]]
    tmp = tmp.score
    tmp = np.array(tmp)
    tmp = tmp.reshape(len(xv), len(br))
    im = plt.imshow(tmp, interpolation='nearest', cmap='gnuplot', vmin = 0, vmax = 1,  extent=[0.05,0.5,1,0.05],
              aspect=0.5)
    xtmp = [0.05, 0.2, 0.3, 0.4, 0.5]
    plt.xticks(xtmp)
    ytmp = [0.05, 0.2, 0.4, 0.6, 0.8, 1.0]
    plt.yticks(ytmp)
    ax.grid(False)
divider = make_axes_locatable(plt.gca())
cax = divider.append_axes("right", "5%", pad="3%")
plt.colorbar(im, cax=cax)
plt.tight_layout()
</code></pre>

<p>and this is what I get:</p>

<p><a href="https://i.stack.imgur.com/ntC9y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ntC9y.png" alt="enter image description here"></a></p>

<p>However I would like to have the same colorbar for all the subplots, for istance on the right side of the figure.</p>