title: Put colorbar on specific hist2d in a subplot of hist and hist2d
body: <p>I have seen a few suggestions of using ImageGrid (like over <a href="https://stackoverflow.com/questions/61062216/adding-one-colorbar-for-hist2d-subplots-and-make-them-adjacent">here</a>) but my issue is that these are all hist2d without different kinds of plots as well.
  Maybe the solution is obvious to some but I am not sure how to specifically show the color map of a hist2d in a specific ax when not all of my other subplots are hist2d.</p>
  <p>Here is an example of my what I am trying to do, with randomly generated data. The titles and such are there based on my actual data, but for the purposes of this demo you can just ignore those.</p>
  <p>Here's the sample code:</p>
  <pre><code># imports
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib as mpl
  
  # seed random number
  np.random.seed(0)
  
  # random normally distributed data
  entries = 100000
  # first signal
  mu1, sigma1 = 0.5, 0.01 # mean and standard deviation
  s1 = np.random.normal(mu1, sigma1, entries)
  # second signal
  mu2, sigma2 = 0.45, 0.02 # mean and standard deviation
  s2 = np.random.normal(mu2, sigma2, entries)
  
  # fig and ax
  fig, ax = plt.subplots(2, 3, figsize = (30, 15))
  
  # fill plots
  ax[0, 0].hist(s1, bins = 100, density = True, range = (0.45, 0.55))
  # log scale for z axis
  ax[0, 1].hist2d(s2, s1, bins = 100, range = ((0.35, 0.55), (0.45, 0.55)), norm = mpl.colors.LogNorm(), cmap = &quot;plasma&quot;)
  ax[0, 2].hist(s2, bins = 100, density = True, range = (0.35, 0.55))
  
  ax[1, 0].hist(s1, bins = 100, density=True, range = (0.45, 0.55))
  # log scale for z axis
  ax[1, 1].hist2d(s2, s1, bins = 100, range = ((0.35, 0.55), (0.45, 0.55)), norm = mpl.colors.LogNorm(), cmap = &quot;plasma&quot;)
  ax[1, 2].hist(s2, bins = 100, density = True, range = (0.35, 0.55))
  
  # plot settings (titles, etc)
  for i in range(0,2):
      for j in range(0,3):
          if i == 0:
              ax[i, j].set_title(r&quot;proton in FD&quot;, fontsize = 22)
          elif i == 1:
              ax[i, j].set_title(r&quot;proton in CD&quot;, fontsize = 22)
          ax[i, j].grid(color = 'black', linestyle = ':', linewidth = 0.5, zorder = 0)
          ax[i, j].ticklabel_format(axis = &quot;y&quot;, style = &quot;sci&quot;, scilimits = (0,0))
  
          # axis names
          if j == 0:
              ax[i, j].set(xlabel = &quot;MM$^2$ [GeV$^2$]&quot;)
              ax[i, j].set(ylabel = &quot;Count&quot;)
          if j == 1:
              ax[i, j].set(xlabel = &quot;IM($2\gamma$) [GeV]&quot;)
              ax[i, j].set(ylabel = &quot;MM$^2$ [GeV$^2$]&quot;)
          if j == 2:
              ax[i, j].set(xlabel = &quot;IM($2\gamma$) [GeV]&quot;)
              ax[i, j].set(ylabel = &quot;Count&quot;)
  
  fig.suptitle(&quot;final states: full data skim $ep\gamma$ + any additional particles&quot;, fontsize=25)
  plt.show()
  </code></pre>
  <p>And here is the output I get of the above code:</p>
  <p><a href="https://i.stack.imgur.com/DEq5W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DEq5W.png" alt="enter image description here" /></a></p>
  <p>What I would like to be able to do is put the colorbar for the two hist2d images, but when I try to do something like ax[0,1].colorbar() I get the issue that ax doesn't have colorbar. I would have to use fig.colorbar() or plt.colorbar() and I am not sure how to use that to show for a specific subplot.</p>
  <p>Is there a way to do this? Thank you for the help.</p>