Use GridSpec to create your own set of subtasks, then add a colored row to the last column.
Example:
import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec fig = plt.figure() gs = gridspec.GridSpec(2, 3, width_ratios=[10,10,1]) ax = np.empty([2,3],dtype=np.object) im = np.empty([2,2],dtype=np.object) for m in range(2): for n in range(2): ax[m,n] = plt.subplot(gs[m,n]) im[m,n] = ax[m,n].imshow(np.random.rand(10,10)) for i in range(2): ax[i,2] = plt.subplot(gs[i,2]) plt.colorbar(im[i,1],cax=ax[i,2]) plt.show()
See also: Python / Matplotlib - Resize Subtitle Relative Size
source share