Title: [BUG]: Button widgets don't work in inset axes · Issue #25030 · matplotlib/matplotlib · GitHub
Open Graph Title: [BUG]: Button widgets don't work in inset axes · Issue #25030 · matplotlib/matplotlib
X Title: [BUG]: Button widgets don't work in inset axes · Issue #25030 · matplotlib/matplotlib
Description: Summary If I modify the check button example to put the buttons in an inset axes: diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 493ac4c3e7..574bad6780 100644 --- a/examples/widgets/check_buttons...
Open Graph Description: Summary If I modify the check button example to put the buttons in an inset axes: diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 493ac4c3e7..574bad6780 100...
X Description: Summary If I modify the check button example to put the buttons in an inset axes: diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 493ac4c3e7..574bad6780 100...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25030
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG]: Button widgets don't work in inset axes","articleBody":"### Summary\n\nIf I modify the check button example to put the buttons in an inset axes:\r\n```diff\r\ndiff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py\r\nindex 493ac4c3e7..574bad6780 100644\r\n--- a/examples/widgets/check_buttons.py\r\n+++ b/examples/widgets/check_buttons.py\r\n@@ -23,12 +23,11 @@ fig, ax = plt.subplots()\r\n l0, = ax.plot(t, s0, visible=False, lw=2, color='k', label='2 Hz')\r\n l1, = ax.plot(t, s1, lw=2, color='r', label='4 Hz')\r\n l2, = ax.plot(t, s2, lw=2, color='g', label='6 Hz')\r\n-fig.subplots_adjust(left=0.2)\r\n \r\n lines_by_label = {l.get_label(): l for l in [l0, l1, l2]}\r\n \r\n # Make checkbuttons with all plotted lines with correct visibility\r\n-rax = fig.add_axes([0.05, 0.4, 0.1, 0.15])\r\n+rax = ax.inset_axes([0.0, 0.0, 0.12, 0.2])\r\n check = CheckButtons(\r\n ax=rax,\r\n labels=lines_by_label.keys(),\r\n```\r\nthen the check buttons are not responsive in the inset axes. Clicking on them does nothing.\r\n\r\nIf I just put them in a regular Axes that happens to overlay the main one, then everything works fine:\r\n```diff\r\ndiff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py\r\nindex 493ac4c3e7..574bad6780 100644\r\n--- a/examples/widgets/check_buttons.py\r\n+++ b/examples/widgets/check_buttons.py\r\n@@ -23,12 +23,12 @@ fig, ax = plt.subplots()\r\n l0, = ax.plot(t, s0, visible=False, lw=2, color='k', label='2 Hz')\r\n l1, = ax.plot(t, s1, lw=2, color='r', label='4 Hz')\r\n l2, = ax.plot(t, s2, lw=2, color='g', label='6 Hz')\r\n-fig.subplots_adjust(left=0.2)\r\n \r\n lines_by_label = {l.get_label(): l for l in [l0, l1, l2]}\r\n \r\n # Make checkbuttons with all plotted lines with correct visibility\r\n-rax = fig.add_axes([0.05, 0.4, 0.1, 0.15])\r\n+bbox = ax.get_position()\r\n+rax = fig.add_axes([bbox.x0, bbox.y0, 0.12, 0.2])\r\n check = CheckButtons(\r\n ax=rax,\r\n labels=lines_by_label.keys(),\r\n```\n\n### Proposed fix\n\n_No response_","author":{"url":"https://github.com/QuLogic","@type":"Person","name":"QuLogic"},"datePublished":"2023-01-19T10:21:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/25030/matplotlib/issues/25030"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8b7f43b9-976e-c779-4908-c19f77b4963b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F0C:196E75:A1675:D95A0:6A52BDCE |
| html-safe-nonce | 83fa091f31c499bdb8cd660eaa821fd5861726f85b5180c4c94d58c2efa3d64a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjBDOjE5NkU3NTpBMTY3NTpEOTVBMDo2QTUyQkRDRSIsInZpc2l0b3JfaWQiOiIxODQwMTIwMTAwNTY2NTE1MTUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 09cbea499a3be712dcea1e1025d7cecdb08718c4838e26e1512adab772e49ca5 |
| hovercard-subject-tag | issue:1548874147 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/25030/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96b1bfe7ae773f1797c5a6646f8db014a909dc797e4eb6f1acdaf0f3f53aa85f/matplotlib/matplotlib/issues/25030 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96b1bfe7ae773f1797c5a6646f8db014a909dc797e4eb6f1acdaf0f3f53aa85f/matplotlib/matplotlib/issues/25030 |
| og:image:alt | Summary If I modify the check button example to put the buttons in an inset axes: diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 493ac4c3e7..574bad6780 100... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | QuLogic |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| 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 | false |
| 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