Title: Plot disappear when blit is on · Issue #17685 · matplotlib/matplotlib · GitHub
Open Graph Title: Plot disappear when blit is on · Issue #17685 · matplotlib/matplotlib
X Title: Plot disappear when blit is on · Issue #17685 · matplotlib/matplotlib
Description: Already posted on stackoverflow but here should be more appropriate. Bug report Bug summary First, good morning. As the title describes, my plot disappears when the blitting option is on. I explain a bit further : I am making animations ...
Open Graph Description: Already posted on stackoverflow but here should be more appropriate. Bug report Bug summary First, good morning. As the title describes, my plot disappears when the blitting option is on. I explain...
X Description: Already posted on stackoverflow but here should be more appropriate. Bug report Bug summary First, good morning. As the title describes, my plot disappears when the blitting option is on. I explain...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/17685
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Plot disappear when blit is on","articleBody":"Already posted on stackoverflow but here should be more appropriate.\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nFirst, good morning.\r\nAs the title describes, my plot disappears when the blitting option is on. I explain a bit further : I am making animations to display the solution of some differential equations and the code will become more and more heavy. I need the blitting option to have smooth animations\r\n and not to \"render\" the widgets everytime but I also need a button to start/stop the animation. I am using FuncAnimation. The thing is when I stop the animation with the \"myAnimation.event_source.stop()\" command linked to a widget button, the plot disappears (in some cases the moment my mouse cursor gets out of the pause button, some cases as soon as I press the button). The ax stays empty as long as the animation is on pause and the plot comes back animated when I restart with \"myAnimation.event_source.start()\".\r\n\r\n**Code for reproduction**\r\nA mock version of the code that is not the code I'm trying to write but simplifies the computations and makes it more readable.\r\n\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.animation as animation\r\n\r\nclass plotanimation:\r\n def __init__(self):\r\n self.fig,self.ax=plt.subplots()\r\n self.x=np.linspace(-10,10,1000)\r\n self.N=200\r\n self.interv=50\r\n self.n0=1./(4*np.pi*2e-4*0.1)**0.5 * np.exp(-self.x**2/(4*2e-4*0.1)) \r\n self.p,=self.ax.plot(self.x,self.n0)\r\n self.anim_running = True\r\n self.Myanimation=animation.FuncAnimation(self.fig, self.update,frames=self.N,interval=self.interv,blit=True)\r\n def update(self,i):\r\n self.n0+=i/100\r\n self.p.set_ydata(self.n0)\r\n return self.p,\r\n def animate(self):\r\n pause_ax = self.fig.add_axes((0.7, 0.025, 0.1, 0.04))\r\n pause_button = Button(pause_ax, 'pause', hovercolor='0.975')\r\n pause_button.on_clicked(self._pause)\r\n plt.show()\r\n def _pause(self, event):\r\n if self.anim_running:\r\n self.Myanimation.event_source.stop()\r\n self.anim_running = False\r\n else:\r\n self.Myanimation.event_source.start()\r\n self.anim_running = True\r\n \r\n \r\nanimated_plot = plotanimation()\r\nanimated_plot.animate()\r\n```\r\n\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\nThe paused plot on the fig. Not an empty ax.\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: W10\r\n * Matplotlib version: (3.1.2)\r\n * Matplotlib backend : TkAgg\r\n * Python version: v3.8.1:1b293b6\r\n * Jupyter version (if applicable): None\r\n * Other libraries: Numpy, scipy\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\nMatplotlib was installed with pip. Conda is not installed.\r\nThank you a lot.","author":{"url":"https://github.com/Luluser","@type":"Person","name":"Luluser"},"datePublished":"2020-06-19T08:09:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/17685/matplotlib/issues/17685"}
| 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:d5b48fe6-48fa-8c6c-ba2a-7fb199feed14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84E2:1ECA58:CA058B:10CE705:6A52C477 |
| html-safe-nonce | 954dd2623266f1f1f6556b57a63b26ace796fd6de2a8d2b8315475a7884703f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEUyOjFFQ0E1ODpDQTA1OEI6MTBDRTcwNTo2QTUyQzQ3NyIsInZpc2l0b3JfaWQiOiIxNjY5NzQwNDUzMDM2MjEzMzY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9d559ef07541587323d192070fa78f64d903f1bc3b49b12631aeec02e566e120 |
| hovercard-subject-tag | issue:641790867 |
| 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/17685/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df4432fa3277ab25aab69b840b743a7ae32bd9d21d78f351d4c41efc19772e27/matplotlib/matplotlib/issues/17685 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df4432fa3277ab25aab69b840b743a7ae32bd9d21d78f351d4c41efc19772e27/matplotlib/matplotlib/issues/17685 |
| og:image:alt | Already posted on stackoverflow but here should be more appropriate. Bug report Bug summary First, good morning. As the title describes, my plot disappears when the blitting option is on. I explain... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Luluser |
| 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