Closed
Description
How would everyone feel about the following change? It will show the z
value of a scalar image in the cursor if available (similar to what Matlab does). If there is no image or the image is RGB, it will revert to the previous behaviour.
--- a/lib/matplotlib/axes/_base.py
+++ b/lib/matplotlib/axes/_base.py
@@ -2971,7 +2971,12 @@ class _AxesBase(martist.Artist):
ys = '???'
else:
ys = self.format_ydata(y)
- return 'x=%s y=%s' % (xs, ys)
+ try:
+ z = self.images[0].get_array()[int(y + 0.5), int(x + 0.5)]
+ zs = self.format_xdata(z)
+ return 'x=%s y=%s z=%s' % (xs, ys, zs)
+ except:
+ return 'x=%s y=%s' % (xs, ys)
def minorticks_on(self):
'Add autoscaling minor ticks to the axes.'
Metadata
Metadata
Assignees
Labels
No labels