title: colorbar changes the size of subplot in python
body: <p>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</p>
  
  <pre class="lang-py prettyprint-override"><code>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', interpolation='nearest')
      plt.axis('off')
      plt.title('dog')
      divider = make_axes_locatable(ax1)
      cax = divider.append_axes("right", size="5%", pad=0.05)
      plt.colorbar(imc, cax=cax)
      plt.tight_layout() 
      plt.show()
  </code></pre>
  
  <p>However it comes out the size of side-by-side images are not equal. I wonder how I could fix this issue?<a href="https://i.stack.imgur.com/PmPyv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PmPyv.png" alt="enter image description here"></a></p>