colorbar changes the size of subplot in python
问题 I use the following code to generate side-by-size images and I need to add colorbar only to the second image in the row. I use the following code for it import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import matplotlib.gridspec as gridspec def plotting(x): gs1 = gridspec.GridSpec(1, 2) gs1.update(wspace=0.005, hspace=0.005) plt.subplot(gs1[0]) plt.imshow(x) plt.axis('off') plt.title('dog') ax1 = plt.subplot(gs1[1]) imc = plt.imshow(x, cmap='hot',