I need to build a grid with the values of the "temperature map", which I currently use imshow, with the color map. This is described in a Matplotlib review , so I modified the example to customize the custom aspect of the picture:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np
plt.figure()
ax = plt.gca()
im = ax.imshow(np.arange(100).reshape((10,10)), aspect=0.5)
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im, cax=cax)
plt.savefig("test.png")
But the result is not the one I want, the color bar is above the main axis: 
Interestingly, when the color map is horizontal, it scales correctly:
cax = divider.append_axes("bottom", size="5%", pad=0.05)
plt.colorbar(im, cax=cax, orientation="horizontal")

source
share