Title: Updating a plot doesn't clear old plots, if event trigger came from another figure? · Issue #10183 · matplotlib/matplotlib · GitHub
Open Graph Title: Updating a plot doesn't clear old plots, if event trigger came from another figure? · Issue #10183 · matplotlib/matplotlib
X Title: Updating a plot doesn't clear old plots, if event trigger came from another figure? · Issue #10183 · matplotlib/matplotlib
Description: Bug report Bug summary I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if the trigger came from another figure, then...
Open Graph Description: Bug report Bug summary I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if th...
X Description: Bug report Bug summary I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if th...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10183
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Updating a plot doesn't clear old plots, if event trigger came from another figure?","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\nI am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if the trigger came from another figure, then weird results happen: the line that's been updated appears to leave its trace uncleared.\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\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\ndef onclick(event):\r\n\r\n for ii in np.linspace(0., np.pi, 100):\r\n y1 = y * np.sin(ii)\r\n line1.set_ydata(y1)\r\n ax.draw_artist(line1)\r\n line2.set_ydata(-y1)\r\n ax2.draw_artist(line2)\r\n ax2.set_ylim(y1.min(), y1.max())\r\n fig.canvas.update()\r\n plt.pause(0.1)\r\n\r\n\r\nx = np.linspace(0., 2*np.pi, 100)\r\ny = np.sin(x)\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(1, 2, 1)\r\nline1 = ax.plot(x, y)[0]\r\n\r\nax2 = fig.add_subplot(1, 2, 2)\r\nline2 = ax2.plot(x, y)[0]\r\n\r\n\r\nfig2 = plt.figure()\r\n\r\ncid = fig2.canvas.mpl_connect('button_press_event', onclick)\r\n# cid = fig.canvas.mpl_connect('button_press_event', onclick)\r\n\r\nplt.show()\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\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\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\nNot the many curves saw in the above figure, just one curve being updated in each cycle. In the code snippet, if use\r\n\r\n cid = fig.canvas.mpl_connect('button_press_event', onclick)\r\n\r\nthen it works as intended.\r\n\r\nAlso note, if you resize the plot, or save it as figure, then all the residue curves will be gone.\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: windows\r\n * Matplotlib version: 2.0.0\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt4Agg\r\n * Python version: 2.7\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\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/clsmt","@type":"Person","name":"clsmt"},"datePublished":"2018-01-06T19:49:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/10183/matplotlib/issues/10183"}
| 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:b03bf33b-95cf-df72-f1f6-67230c530ee3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9438:FAECF:1A06BCE:22798EE:6A52CB8E |
| html-safe-nonce | 20e9b1838e1a0bd7d80420528b31bd5769407f108d44555d4a7ec2002d71efe9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDM4OkZBRUNGOjFBMDZCQ0U6MjI3OThFRTo2QTUyQ0I4RSIsInZpc2l0b3JfaWQiOiI1MTEwNTc3MDA4ODU5MDczNDIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 07d86afbc7fcd95a4efcc671cea800ac260df1418034318e0fc8cd96798de687 |
| hovercard-subject-tag | issue:286513090 |
| 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/10183/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04e519d3a2f6cf7e5bebc965dda4b51fa1c0c7b1dc308172347c117e18d24033/matplotlib/matplotlib/issues/10183 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04e519d3a2f6cf7e5bebc965dda4b51fa1c0c7b1dc308172347c117e18d24033/matplotlib/matplotlib/issues/10183 |
| og:image:alt | Bug report Bug summary I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | clsmt |
| 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