title: Matplotlib - can't set the size of my colobar with a broken axis scatter plot
body: <p>I am trying to set my colorbar to the same lenght as my broken axis scatter plot but I can't seem to make it worked. I have tried to use</p>
  <pre><code>divider = make_axes_locatable(ax2)
  cax = divider.append_axes(&quot;right&quot;,size='5%', pad=0.05) 
  </code></pre>
  <p>but I get a super long colorbar. This is my code below</p>
  <pre><code>fig, (ax, ax2) = plt.subplots(1, 2, sharey=True, gridspec_kw={'width_ratios': [6, 1]})
  
  
  scatter = ax.scatter(Coef_fam_cd,Coef_member_cd,c=lenght_cd,cmap='viridis_r')
  ax2.scatter(Coef_fam_cd,Coef_member_cd,c=lenght_cd,cmap='viridis_r')
  ax.set_xlim(0,5)
  ax2.set_xlim(18.9,20)
  
  # hide the spines between ax and ax2
  ax.spines['right'].set_visible(False)
  ax2.spines['left'].set_visible(False)
  ax.yaxis.tick_left()
  ax.tick_params(labelright=False)
  ax2.yaxis.tick_right()
  
  # This looks pretty good, and was fairly painless, but you can get that
  # cut-out diagonal lines look with just a bit more work. The important
  # thing to know here is that in axes coordinates, which are always
  # between 0-1, spine endpoints are at these locations (0,0), (0,1),
  # (1,0), and (1,1).  Thus, we just need to put the diagonals in the
  # appropriate corners of each of our axes, and so long as we use the
  # right transform and disable clipping.
  
  d = .01 # how big to make the diagonal lines in axes coordinates
  # arguments to pass plot, just so we don't keep repeating them
  kwargs = dict(transform=ax.transAxes, color='k', clip_on=False)
  ax.plot((1-d,1+d), (-d,+d), **kwargs)
  ax.plot((1-d,1+d),(1-d,1+d), **kwargs)
  
  kwargs.update(transform=ax2.transAxes)  # switch to the bottom axes
  ax2.plot((-d,+d), (1-d,1+d), **kwargs)
  ax2.plot((-d,+d), (-d,+d), **kwargs)
  
  
  
  cbar = plt.colorbar(scatter)
  
  
  
  
  cbar.ax.tick_params(rotation=90)
  cbar.ax.set_ylabel('Number of members in a family')
  plt.ylim(0,5)
  fig.subplots_adjust(right=1)
  
  
  ax2.yaxis.set_visible(False)
  
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Js2kJ.png" rel="nofollow noreferrer">my graph</a></p>
  <p>thank you for your help.</p>