Title: [Bug]: twin axes ignore the navigation opt-outs · Issue #32528 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: twin axes ignore the navigation opt-outs · Issue #32528 · matplotlib/matplotlib
X Title: [Bug]: twin axes ignore the navigation opt-outs · Issue #32528 · matplotlib/matplotlib
Description: Bug summary set_navigate(False) on a twinx() axes, and set_forward_navigation_events(False) on its partner, are both ignored: the toolbar adds twinned siblings to the navigation set unconditionally, so a zoom rectangle moves both y scale...
Open Graph Description: Bug summary set_navigate(False) on a twinx() axes, and set_forward_navigation_events(False) on its partner, are both ignored: the toolbar adds twinned siblings to the navigation set unconditionally...
X Description: Bug summary set_navigate(False) on a twinx() axes, and set_forward_navigation_events(False) on its partner, are both ignored: the toolbar adds twinned siblings to the navigation set unconditionally...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/32528
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: twin axes ignore the navigation opt-outs","articleBody":"### Bug summary\n\nset_navigate(False) on a twinx() axes, and set_forward_navigation_events(False) on its partner, are both ignored: the toolbar adds twinned siblings to the navigation set unconditionally, so a zoom rectangle moves both y scales.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nt = np.linspace(0.0, 10.0, 600)\ny = np.linspace(0.0, 1.0, 200)\nz = np.exp(-(y[:, None] - 0.5 - 0.3 * np.sin(t)) ** 2 / (2 * 0.04 ** 2)) # any image will do\n\nfig, ax = plt.subplots()\nax2 = ax.twinx()\nax2.imshow(z, extent=[t[0], t[-1], 0.0, 1.0], aspect=\"auto\") # its own y, on [0, 1]\nax2.patch.set_visible(False) # the standard overlay recipe\nax.set_zorder(ax2.get_zorder() + 1)\nax.patch.set_visible(False)\nax.plot(t, np.exp(-t / 6.0) - np.exp(-t), color=\"C0\") # a pulse for the second image\n\nax2.set_navigate(False) # both opt-outs, as explicitly as the API allows\nax.set_forward_navigation_events(False)\nplt.show()\n```\n\n### Actual outcome\n\nWith the zoom tool selected, drag a rectangle over the middle of the axes. Both images zoom.\n\n### Expected outcome\n\nOnly the image with the focus should be navigated, not the twin.\n\n### Additional information\n\nIn `NavigationToolbar2._start_event_axes_interaction` (`lib/matplotlib/backend_bases.py`) the\nsiblings are appended before the capture test and without consulting `get_navigate()`:\n\n```python\naxes_to_trigger.append(ax)\n# NOTE: shared axes are automatically triggered, but twin-axes not!\naxes_to_trigger.extend(ax._twinned_axes.get_siblings(ax))\n\nif _capture_events(ax):\n break\n```\n\nSo neither opt-out applies. This looks like the remaining gap in the feature added for #1502\n(\"twin axis panning / zooming should be toggleable\", closed as fixed by #27148 for 3.9.0):\nthe toggle exists and works between overlapping axes, but not for a twin.\n\nA conservative fix would filter the siblings through the same predicate already applied to the\naxes themselves, so a twin that declines navigation is simply not added and existing behaviour\nis unchanged for everyone else.\n\nThe visible symptom, in an overlay where the back axes holds a fixed image and the front axes a curve, is that dragging a rectangle over the shared position stretches the image vertically while the curve's y stays put. In the live instance, y zooming on the front image was disabled, and that happened correctly, but the fixed background image continued to zoom the y axis in an undesirable way.\n\nOn existing reports: #1502 (\"twin axis panning / zooming should be toggleable\") is the feature request this belongs to and is closed as fixed by #27148 for 3.9.0; I am not reopening it because its request has been met; the toggle exists, and what fails is that it does not reach twins. #9616 (\"second y-axis does not scale correctly when using the zoom tool\") was closed pointing at secondary_yaxis, so I expect the same suggestion here, and it is worth saying in advance why it does not fit: secondary_yaxis derives the second scale from the first by a pair of functions, so it suits a conversion (Fahrenheit/Celsius) but cannot host an independent overlay—in my case the back axes holds data in different units, but neither should be scaled on the yaxis.\n\nDisclosure: the first draft of this report, and the reproduction above, were written by an AI agent working in Open Math OS from my observations; I have run the reproduction myself, understood the issues, and edited as appropriate.\n\nThe full application for context is here: https://github.com/dpthurst/core-entropy-app\n(The standalone app, not the web version using Plotly.)\n\n### Operating system\n\nDebian\n\n### Matplotlib Version\n\n3.10.1+dfsg1\n\n### Matplotlib Backend\n\nqtagg\n\n### Python version\n\nPython 3.13.5\n\n### Jupyter version\n\nN/A\n\n### Installation\n\nLinux package manager","author":{"url":"https://github.com/dpthurst","@type":"Person","name":"dpthurst"},"datePublished":"2026-10-23T02:14:27Z","url":"https://github.com/matplotlib/matplotlib/issues/32528"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:f635c520-9b4c-ac2d-d389-708fe174454f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EAC6:29E85A:9A01E1:CF0457:6B064EE4 |
| html-safe-nonce | 6a3fc90ef6faac5a0cfac128eaffcbd6a6bdb93974a9ac3c97382cadedccaadd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUM2OjI5RTg1QTo5QTAxRTE6Q0YwNDU3OjZCMDY0RUU0IiwidmlzaXRvcl9pZCI6IjU0NzIwNTc1MTg2NjAxOTU1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fc3f4ab916842b4b37c1e585d5076879a51d62113365bce1fc5231b544242a89 |
| hovercard-subject-tag | issue:5990664030 |
| 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/32528/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a2be7527c673b20cb473f3608b9d4964969566d1cf973218e19ae8c745c2366/matplotlib/matplotlib/issues/32528 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a2be7527c673b20cb473f3608b9d4964969566d1cf973218e19ae8c745c2366/matplotlib/matplotlib/issues/32528 |
| og:image:alt | Bug summary set_navigate(False) on a twinx() axes, and set_forward_navigation_events(False) on its partner, are both ignored: the toolbar adds twinned siblings to the navigation set unconditionally... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dpthurst |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| 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 | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width