matplotlib colorbar in each subplot

This can be easily solved with the the utility make_axes_locatable. I provide a minimal example that shows how this works and should be readily adaptable: import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import numpy as np m1 = np.random.rand(3, 3) m2 = np.arange(0, 3*3, 1).reshape((3, 3)) fig = plt.figure(figsize=(16, 12)) ax1 = fig.add_subplot(121) im1 … Read more

How to animate the colorbar in matplotlib

While I’m not sure how to do this specifically using an ArtistAnimation, using a FuncAnimation is fairly straightforward. If I make the following modifications to your “naive” version 1 it works. Modified Version 1 import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from mpl_toolkits.axes_grid1 import make_axes_locatable fig = plt.figure() ax = … Read more

Scientific notation colorbar in matplotlib

You could use colorbar‘s format parameter: import matplotlib.pyplot as plt import numpy as np import matplotlib.ticker as ticker img = np.random.randn(300,300) myplot = plt.imshow(img) def fmt(x, pos): a, b = ‘{:.2e}’.format(x).split(‘e’) b = int(b) return r’${} \times 10^{{{}}}$’.format(a, b) plt.colorbar(myplot, format=ticker.FuncFormatter(fmt)) plt.show()