Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Matplotlib blitting in Jupyter Notebooks (issue #4288)#9240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
jklymak commentedSep 27, 2017
Hi, I'm unsure as well how to do a scripted notebook test as well. However, to start you could post your test code that can be pasted into a reviewers notebook. |
blink1073 commentedSep 27, 2017
tacaswell commentedSep 27, 2017
@mbewley Thanks for taking this on! If you have any questions (code or process) please do not hesitate to ask! You will probably get faster answers asking publically (here or onhttps://gitter.im/matplotlib/matplotlib ) but if there is anything you do not feel comfortable asking publicly email me. |
mbewley commentedSep 27, 2017
Here's the minimal example that works inside a notebook... just click on the generated 49 MP image, and it will rapidly toggle a little red/green box in the top left. |
pelson commentedOct 11, 2017
Looks like a sensible change (untested). To be clear, the blitting you are adding is on the server side - you aren't getting any blitting through the javascript and into the notebook. That's fine (and a hard problem to solve), but we should be careful not to call it full-blown blitting in the nbagg backend.
Wow! Really impressive stuff - there is a lot of connective tissue you've had to get your head around, and you've done a great job of it as far as I can see! Keep up the awesome work - looking forward to seeing your future mpl contributions 👍 |
mbewley commentedOct 12, 2017
Ha, the "connective tissue" was all blink1073 - I just managed to copy/paste correctly (and do a neat minimal example). Yes, the server side blitting works perfectly on local host for fast access. It also works quite quickly on EC2 (tested at work where we have a pretty fast connection), but chews up monstrous amounts of bandwidth - so maybe should come with some sort of warning? |
mbewley commentedOct 19, 2017
Hey guys, is there anything we need to do to make sure this gets into 2.2? (it was slated for 2.1, but got bumped). |
dopplershift commentedOct 20, 2017
I labelled it release critical so that we're sure to take a look at it before the next feature release. |
mbewley commentedOct 20, 2017
Thanks! |
tacaswell commentedJan 3, 2018
power cycled to re-trigger CI. |
tacaswell commentedJan 3, 2018
tacaswell commentedJan 3, 2018
Or put your example in the UAT notebook. |
mbewley commentedJan 4, 2018
Hmm, I didn't see those issues. I've now:
Anything else I need to do? |
mbewley commentedJan 4, 2018
mbewley commentedJan 17, 2018
Hey, any feedback on the updates? |
tacaswell commentedJan 17, 2018
Can you update the UAT notebook as part of this PR? Any theories on the flickering? |
mbewley commentedJan 24, 2018
What did you want updated on the UAT notebook? I added it into the repo and checked it ran - the tests all still seemed sensible. |
tacaswell commentedJan 24, 2018
@mbewley just for the changes to be check-in as part of this PR so that the next person to work on this can run them. |
mbewley commentedJan 24, 2018
Ah, sorry, thought I'd done that - forgot to push. Will do... |
jklymak commentedJan 28, 2018
oops, looks like you accidentally rebased in a bunch of other commits... |
mbewley commentedJan 28, 2018
Hmm, I was trying to update to the latest head on master, as it was getting pretty old. What's the best way to fix it? |
jklymak commentedJan 29, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
To rebase, I always squash my own commits Then I rebase with master: See: When I've gotten in the state that you are in, I copy the files I edited somewhere else and then in my branch: and then re-add the changes. |
mbewley commentedJan 29, 2018
Ok, I thought I followed this:https://matplotlib.org/devel/gitwash/development_workflow.html#development-workflow ("Rebasing on Trunk"), but must've stuffed it up. Will fix and push again. |
… compatibility with latest jupyter notebook).
astrofrog commentedApr 16, 2019
| self._last_renderer,renderer) | ||
| self.figure._cachedRenderer=self._renderer | ||
| foraxinself.figure.axes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
we don't cache the renderer on the axes anymore, so these two lines should go away
jklymak commentedJul 16, 2019
ping@mbewley - sometimes takes a while to get things through matplotlib - hopefully the process hasn't scared you off! |
tacaswell commentedSep 5, 2019
This still does not deal with the double-buffering correctly. For example in %matplotlibnotebookimportnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlib.animationimportFuncAnimationfig,ax=plt.subplots()xdata,ydata= [], []ln,=plt.plot([], [],'ro')definit():ax.set_xlim(0,2*np.pi)ax.set_ylim(-1,1)returnln,defupdate(frame):xdata.append(frame)ydata.append(np.sin(frame))ln.set_data(xdata,ydata)returnln,ani=FuncAnimation(fig,update,frames=np.linspace(0,2*np.pi,128),init_func=init,blit=True)plt.show() every other frame has the incorrect tick labels. I think instead of using two |
Replaced the second Agg renderer by storing the previous buffer in a private attribute. Removing the second renderer eliminates the the flickering issues noted in:matplotlib#9240 (comment)Also, did not need to implement copy_from_bbox as that is inherited from backend_agg.FigureCanvasAgg
Replaced the second Agg renderer by storing the previous buffer in a private attribute. Removing the second renderer eliminates the the flickering issues noted in:matplotlib#9240 (comment)Also, did not need to implement copy_from_bbox as that is inherited from backend_agg.FigureCanvasAgg
…g figuretaking the example frommatplotlib#9240Co-Authored-By: Thomas A Caswell <tcaswell@gmail.com>
…g figuretaking the example frommatplotlib#9240Co-Authored-By: Thomas A Caswell <tcaswell@gmail.com>
…g figuretaking the example frommatplotlib#9240Co-Authored-By: Thomas A Caswell <tcaswell@gmail.com>
jklymak commentedJun 14, 2021
I'll closed as abandoned; thanks for the PR, and feel free to re-open if you want to come back to this! |
ianhi commentedJun 28, 2021
For any future finders of this PR: This was subsumed and then superceded by#19059 |
PR Summary
Blitting is not currently supported by matplotlib when used in Jupyter notebooks (with the magic %matplotlib notebook).
@blink1073 wrote some code to make it work some time back, but didn't merge it in. I've taken his changes (he said he wasn't interested in doing it himself), and applied them to the latest version of matplotlib.
This is discussed in issue#4288. I was asked to do the pull request - first time contributor to matplotlib. I've tested it with a minimal example Jupyter notebook, but am unsure how to test whether blitting works in notebooks in scripted unit tests.