.. _api-image_zcoord: api example code: image_zcoord.py ================================= .. plot:: /home/tcaswell/other_source/matplotlib/doc/mpl_examples/api/image_zcoord.py :: """ Show how to modify the coordinate formatter to report the image "z" value of the nearest pixel given x and y """ import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm X = 10*np.random.rand(5,3) fig, ax = plt.subplots() ax.imshow(X, cmap=cm.jet, interpolation='nearest') numrows, numcols = X.shape def format_coord(x, y): col = int(x+0.5) row = int(y+0.5) if col>=0 and col=0 and row