Title: fix detecting which artist(s) the mouse is over by megies · Pull Request #10356 · matplotlib/matplotlib · GitHub
Open Graph Title: fix detecting which artist(s) the mouse is over by megies · Pull Request #10356 · matplotlib/matplotlib
X Title: fix detecting which artist(s) the mouse is over by megies · Pull Request #10356 · matplotlib/matplotlib
Description: There is a bug in how moving the mouse over the plot detects what artist should be used to collect additional info about the cursor position from (in my case several Images in the axes). For a plot with multiple images this means that only one image is properly reporting z coordinates and all other images won't be able to show z coordinate info. Example: import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() ax.imshow(np.random.randn(25).reshape(5, 5), extent=[0, 3, 0, 1]) ax.imshow(np.random.randn(25).reshape(5, 5), extent=[0, 3, 2, 3]) ax.set_ylim(0, 3) plt.show() Only moving through one of the images shows correct z coordinates in the interactive window info bar at the bottom. The reason for this bug is an oversight in #3989: Since Artist.contains() returns a tuple it is not usable like this: if my_artist.contains(): ... So, what is happening is that all artists are included in the list of artists that contain the event and then the wrong artist is queried for data on the location of the event. Since the name of the method "contains" might easily in the future be prone to such bugs again, I think a better solution would be to change the return from a 2-tuple (which will always evaluate to True) to only False (not contained) or a dictionary (contained) that in minimal fashion is set up like {'artist': self} so that it evaluates to True. But obviously that would drastically change a public API, so I'm assuming this won't be an option, likely.. Sorry, I'm not sure how to best test this, I think to add a test would mean to first refactor NavigationToolbar2.mouse_move() so that getting the cursor info from all artists is in a separate helper method.. PR Checklist Has Pytest style unit tests Code is PEP 8 compliant no new features New features are documented, with examples if plot related no new docs Documentation is sphinx and numpydoc compliant no new feature Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) no API change Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: There is a bug in how moving the mouse over the plot detects what artist should be used to collect additional info about the cursor position from (in my case several Images in the axes). For a plot...
X Description: There is a bug in how moving the mouse over the plot detects what artist should be used to collect additional info about the cursor position from (in my case several Images in the axes). For a plot...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/10356
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e25040b4-f0d6-9744-3482-dc26dc90cbd0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CD48:3F1247:122088D:18D6A9A:6A53CD96 |
| html-safe-nonce | 018b51350bdb6c4d8e2cd4b36ca2c59edf24fb82c23b209ec1587cbcdbb37038 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDQ4OjNGMTI0NzoxMjIwODhEOjE4RDZBOUE6NkE1M0NEOTYiLCJ2aXNpdG9yX2lkIjoiOTAwMDk2NzQwMDcxMjI5Mzc4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 33f7c8213ea589fd384a2ed634ed305ac2d24f20873ad4a51c351a53796465c3 |
| hovercard-subject-tag | pull_request:166304767 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/10356/files |
| twitter:image | https://avatars.githubusercontent.com/u/1842780?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1842780?s=400&v=4 |
| og:image:alt | There is a bug in how moving the mouse over the plot detects what artist should be used to collect additional info about the cursor position from (in my case several Images in the axes). For a plot... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width