Title: document event handling with twined axes · Issue #10009 · matplotlib/matplotlib · GitHub
Open Graph Title: document event handling with twined axes · Issue #10009 · matplotlib/matplotlib
X Title: document event handling with twined axes · Issue #10009 · matplotlib/matplotlib
Description: Bug report Bug summary In matplotlib 2.1.0 it was possible to define a SpanSelector attached to an axes object, then define another axes system connected to the first one with twinx or twiny. The SpanSelector was still active and returni...
Open Graph Description: Bug report Bug summary In matplotlib 2.1.0 it was possible to define a SpanSelector attached to an axes object, then define another axes system connected to the first one with twinx or twiny. The S...
X Description: Bug report Bug summary In matplotlib 2.1.0 it was possible to define a SpanSelector attached to an axes object, then define another axes system connected to the first one with twinx or twiny. The S...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"document event handling with twined axes","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\nIn matplotlib 2.1.0 it was possible to define a SpanSelector attached to an axes object,\r\nthen define another axes system connected to the first one with twinx or twiny.\r\nThe SpanSelector was still active and returning the values on the first axes object.\r\n\r\nWith matplotlib 2.1.1 this is no more working.\r\nThe SpanSelector works only if attached to the latest axes object defined.\r\n\r\nThe same effect happens also when using draggable annotate attached to an axes object.\r\nAfter defining a twin axes, the annotations are no more draggable.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\nAs an example, I include a slight modification of the matplotlib tutorial about the usage\r\nof span_selector:\r\nhttps://matplotlib.org/examples/widgets/span_selector.html\r\n\r\nAt the end of the code I added twin axes which neutralize the span selector.\r\nAfter uncommenting the last three lines, the span selector works again.\r\nWith matplotlib 2.1.0, the code was working without uncommenting the lines.\r\n\r\n```python\r\n#!/usr/bin/env python\r\n\"\"\"\r\nThe SpanSelector is a mouse widget to select a xmin/xmax range and plot the\r\ndetail view of the selected region in the lower axes\r\n\"\"\"\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.widgets import SpanSelector\r\n\r\nfig = plt.figure(figsize=(8, 6))\r\nax = fig.add_subplot(211, facecolor='#FFFFCC')\r\n\r\nx = np.arange(0.0, 5.0, 0.01)\r\ny = np.sin(2*np.pi*x) + 0.5*np.random.randn(len(x))\r\n\r\nax.plot(x, y, '-')\r\nax.set_ylim(-2, 2)\r\nax.set_title('Press left mouse button and drag to test')\r\n\r\n\r\nax2 = fig.add_subplot(212, facecolor='#FFFFCC')\r\nline2, = ax2.plot(x, y, '-')\r\n\r\n\r\ndef onselect(xmin, xmax):\r\n indmin, indmax = np.searchsorted(x, (xmin, xmax))\r\n indmax = min(len(x) - 1, indmax)\r\n print(indmin,indmax)\r\n\r\n thisx = x[indmin:indmax]\r\n thisy = y[indmin:indmax]\r\n line2.set_data(thisx, thisy)\r\n ax2.set_xlim(thisx[0], thisx[-1])\r\n ax2.set_ylim(thisy.min(), thisy.max())\r\n fig.canvas.draw()\r\n\r\n# set useblit True on gtkagg for enhanced performance\r\nspan = SpanSelector(ax, onselect, 'horizontal', useblit=True,\r\n rectprops=dict(alpha=0.5, facecolor='red'))\r\n\r\nax1 = ax.twinx()\r\nax1.get_yaxis().set_tick_params(labelright='on',right='on', direction='in')\r\nax1.set_ylim([0,1])\r\n\r\n# Uncomment here to work with matplotlib 2.1.1 (possible bug)\r\n#span = SpanSelector(ax1, onselect, 'horizontal', useblit=True,\r\n# rectprops=dict(alpha=0.5, facecolor='red'))\r\n\r\n\r\nplt.show()\r\n\r\n\r\n\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\nThe span selector does not work.\r\n\r\n```\r\n# If applicable, paste the console output here\r\n#\r\n#\r\n```\r\n\r\n**Expected outcome**\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\r\nI expected that the spanselector would work.\r\n\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\nThis was working with matplotlib 2.1.0\r\n\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: mac os-x\r\n * Matplotlib version: 2.1.1\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): \r\n * Python version: 3.6.1\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\nconda\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\ndefault\r\n","author":{"url":"https://github.com/darioflute","@type":"Person","name":"darioflute"},"datePublished":"2017-12-14T20:57:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/10009/matplotlib/issues/10009"}
| 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:43c29354-be8f-0507-202b-4da2bbf5d91b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 970A:262613:1571B3:1E0102:6A532E80 |
| html-safe-nonce | 83175372165dad5159e114bc0d49748d1154f3ba927f5e83aaf6df9ed19a2a07 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzBBOjI2MjYxMzoxNTcxQjM6MUUwMTAyOjZBNTMyRTgwIiwidmlzaXRvcl9pZCI6IjQ4MTEzNjE5NTc0OTUxMjM1ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 00f53d6a4a482c739f5d28ed7e6109a68fbf212f129f758d105f3f41759278c7 |
| hovercard-subject-tag | issue:282236550 |
| 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/10009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/422edfd6239e21e0d49c49d98992aab6c56eb29fdddde4c853190d399be9839b/matplotlib/matplotlib/issues/10009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/422edfd6239e21e0d49c49d98992aab6c56eb29fdddde4c853190d399be9839b/matplotlib/matplotlib/issues/10009 |
| og:image:alt | Bug report Bug summary In matplotlib 2.1.0 it was possible to define a SpanSelector attached to an axes object, then define another axes system connected to the first one with twinx or twiny. The S... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | darioflute |
| 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