title: Displaying z value in plot with pcolor: why it works for one of the two figure but not the other?
body: <p>I need to display below the cursor, coordinates (x,y,z) on a 2D plots. Consider this minimal working example (I compactified as much as I could from my longer code).</p>
  
  <p>If you run it, you will see that the Z coordinate is the good one for the second graph but not for the same. But the Z values that should be taken by the function format_coord that I provide to ax.format_coord are updated between my two plots.</p>
  
  <p>Then, I am not sure to understand this behavior.</p>
  
  <p>How can I fix it ?</p>
  
  <p>As a sidenote: I took the function from format_coord from a stackexchange post... That I do not find anymore... If I find it I will attach the link (I am not super confortable with tricks with pyplot, consider me as a beginner).  </p>
  
  <pre><code>import numpy as np
  from matplotlib.pyplot import *
  import matplotlib.pyplot as plt
  import matplotlib.colors as colors
  import matplotlib.cbook as cbook
  
  def format_coord(x, y):
      xarr = X[0,:]
      yarr = Y[:,0]
      if ((x &gt; xarr.min()) &amp; (x &lt;= xarr.max()) &amp; 
          (y &gt; yarr.min()) &amp; (y &lt;= yarr.max())):
          col = np.searchsorted(xarr, x)-1
          row = np.searchsorted(yarr, y)-1
          z = Z[row, col]
          return f'x={x:1.4f}, y={y:1.4f}, z={z:1.4f}   [{row},{col}]'
      else:
          return f'x={x:1.4f}, y={y:1.4f}'
  
  u=list(map(lambda x:pow(10,x),np.arange(-2,1+0.1,0.1).tolist()))
  v=list(map(lambda x:pow(10,x),np.arange(-2,1+0.1,0.1).tolist()))
  
  [X,Y]=np.meshgrid(u,v)
  Z1=np.ones((len(u),len(v)))
  Z2=3*np.ones((len(u),len(v)))
  
  Z=Z1 # Here I change the Z that will be considered in the function
  fig, ax = plt.subplots()
  pcm = ax.pcolor(X, Y, Z1,norm=colors.LogNorm(vmin=Z1.min(), vmax=Z2.max()),
                     cmap='PuBu_r',edgecolors='black')
  plt.xscale('log', basex=10)
  plt.yscale('log', basey=10)
  fig.colorbar(pcm, extend='max')
  ax.format_coord = format_coord
  plt.title('test1')
  print(Z[0,0]) # displays 1 as expected
  plt.show()
  
  Z=Z2 # Here I change the Z that will be considered in the function
  fig, ax = plt.subplots()
  pcm = ax.pcolor(X, Y, Z2,norm=colors.LogNorm(vmin=Z1.min(), vmax=Z2.max()),
                     cmap='PuBu_r',edgecolors='black')
  plt.xscale('log', basex=10)
  plt.yscale('log', basey=10)
  fig.colorbar(pcm, extend='max')
  ax.format_coord = format_coord
  plt.title('test2')
  print(Z[0,0]) # displays 3 as expected
  plt.show()
  </code></pre>