title: Numpy: How to get the max bin position?
body: <p>I want to find the max bin place of a 2d histogram</p>
  
  <pre><code>from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  import numpy as np
  
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  x, y = np.random.rand(2, 100) * 10
  hist, xedges, yedges = np.histogram2d(x, y, bins=20)
  
  elements = (len(xedges) - 1) * (len(yedges) - 1)
  xpos, ypos = np.meshgrid(xedges[:-1]+0.25, yedges[:-1]+0.25)
  
  xpos = xpos.flatten()
  ypos = ypos.flatten()
  zpos = np.zeros(elements)
  dx = 0.5 * np.ones_like(zpos)
  dy = dx.copy()
  dz = hist.flatten()
  
  ax.bar3d(xpos, ypos, zpos, dx, dy, dz, zsort='average')
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/q4ngO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4ngO.png" alt="enter image description here"></a></p>
  
  <p>That is, I want to know the (x,y) of the <code>hist.max()</code>.</p>
  
  <p>I think I can get away with <code>hist.argmax()</code>. But I don't how to deal with the rest (converting 1d position into 2d). Or if there are better solutions?</p>