Skip to content

Support for Scalar Image Cursor Display? #3984

@blink1073

Description

@blink1073

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy