Title: Defining arrowprops in draggable annotation disables the pick_event · Issue #12396 · matplotlib/matplotlib · GitHub
Open Graph Title: Defining arrowprops in draggable annotation disables the pick_event · Issue #12396 · matplotlib/matplotlib
X Title: Defining arrowprops in draggable annotation disables the pick_event · Issue #12396 · matplotlib/matplotlib
Description: Bug report Bug summary In this interactive code, the "pick_event" is used to connect clicks on the x-label, legend's items, and to react when the annotation is dragged. This was working up to matplotlib 2.2.3. Since matplotlib 3.0, these...
Open Graph Description: Bug report Bug summary In this interactive code, the "pick_event" is used to connect clicks on the x-label, legend's items, and to react when the annotation is dragged. This was working up to matpl...
X Description: Bug report Bug summary In this interactive code, the "pick_event" is used to connect clicks on the x-label, legend's items, and to react when the annotation is dragged. This was worki...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12396
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Defining arrowprops in draggable annotation disables the pick_event","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nIn this interactive code, the \"pick_event\" is used to connect clicks on the x-label, legend's items,\r\nand to react when the annotation is dragged. This was working up to matplotlib 2.2.3.\r\nSince matplotlib 3.0, these behaviors are disrupted. \r\nThe problem is in the definition of the arrowprops. When I comment the line with arrowprops,\r\nthe code works again. Unfortunately, I loose the stem of the annotation.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\n#!/usr/bin/env python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\ndef onpick(event):\r\n print(event.artist)\r\n\r\nfig, ax = plt.subplots()\r\nfig.canvas.mpl_connect('pick_event', onpick)\r\nx = np.arange(10)\r\nblueline = ax.plot(x, x * 2 + 10, color='blue', label='blue line')\r\nredline = ax.plot(x, np.sqrt(x), color='red', label='red line')\r\nannotation = ax.annotate(\"note\", xy=(0.15,0.5), xytext=(0.15,0.2),\r\n xycoords ='axes fraction', textcoords = 'axes fraction',\r\n arrowprops=dict(edgecolor='purple',alpha=0.4,arrowstyle='-') # Offending line\r\n )\r\nannotation.draggable()\r\nax.set_xlabel('X', picker=True)\r\nlegend = ax.legend(fancybox=True)\r\nfor legline in legend.get_lines():\r\n legline.set_picker(5) \r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/cbook/__init__.py\", line 215, in process\r\n func(*args, **kwargs)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/backend_bases.py\", line 1675, in pick\r\n self.figure.pick(mouseevent)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py\", line 447, in pick\r\n a.pick(mouseevent)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py\", line 4141, in pick\r\n martist.Artist.pick(self, args[0])\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py\", line 447, in pick\r\n a.pick(mouseevent)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py\", line 429, in pick\r\n inside, prop = picker(self, mouseevent)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/offsetbox.py\", line 1698, in artist_picker\r\n return self.ref_artist.contains(evt)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/text.py\", line 2184, in contains\r\n contains, tinfo = Text.contains(self, event)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/text.py\", line 213, in contains\r\n l, b, w, h = self.get_window_extent().bounds\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/text.py\", line 2359, in get_window_extent\r\n self.update_positions(renderer)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/text.py\", line 2215, in update_positions\r\n self._update_position_xytext(renderer, xy_pixel)\r\n File \"/Users/dfadda/anaconda3/lib/python3.6/site-packages/matplotlib/text.py\", line 2298, in _update_position_xytext\r\n pad = renderer.points_to_pixels(4)\r\nAttributeError: 'NoneType' object has no attribute 'points_to_pixels'\r\n```\r\n\r\n**Expected outcome**\r\n\r\nUp to matplotlib version 2.2.3, when clicking:\r\n\r\n - the 'X' label\r\n\r\n - an item in the legend\r\n\r\n - the annotation 'note'\r\n\r\nthe onpick function was called and the event.artist was printed.\r\nThe annotation was also draggable.\r\n\r\nIn version 3.0, all this does not work anymore, producing the output on the screen described.\r\nWhen commenting the line with \"arrowprops\", the previous behavior is restaured.\r\nUnfortunately, when doing so, it is not possible to trace the connection with the note.\r\n\r\n**Matplotlib version**\r\n\r\n * Operating system: mac osx\r\n * Matplotlib version: 3.0 (it was working up to version 2.2.3)\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg\r\n * Python version: 3.6\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\nMatplotlib was installed with conda, default channel.\r\n\r\n","author":{"url":"https://github.com/darioflute","@type":"Person","name":"darioflute"},"datePublished":"2018-10-04T00:43:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/12396/matplotlib/issues/12396"}
| 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:523d487f-d3ea-499f-b2b2-627b39f36a12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3A2:3020D:C7E3F0:122904F:6A55FDB5 |
| html-safe-nonce | 04e57f3d55c0a5fc46dba71c69f1026b137a78f3dd9e0b5be23e0098c6b16ea0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0EyOjMwMjBEOkM3RTNGMDoxMjI5MDRGOjZBNTVGREI1IiwidmlzaXRvcl9pZCI6IjI4MzIzOTEwMjQ5MzYzNTMyMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 75ba53c80880b2108f9527e656b1f4c35e5fdbcbc491d602bb837dc216d12495 |
| hovercard-subject-tag | issue:366581096 |
| 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/12396/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e9528e5bc2a2434a31f84bebc8dd2a6ad01d5f69cc9f18cb97c65dee0d6679da/matplotlib/matplotlib/issues/12396 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e9528e5bc2a2434a31f84bebc8dd2a6ad01d5f69cc9f18cb97c65dee0d6679da/matplotlib/matplotlib/issues/12396 |
| og:image:alt | Bug report Bug summary In this interactive code, the "pick_event" is used to connect clicks on the x-label, legend's items, and to react when the annotation is dragged. This was working up to matpl... |
| 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 | f4368738fc918fecd9b3958f6b49218bbe60d4185f38e72e3954e11f1ad0213a |
| 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 | ed27e29ef37c0e8f612ea3fed8118b955b8314e2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width