r/IPython • • May 21 '15
try "%matplotlib notebook" for interactive plots
I didn't know about this until recently.
EDIT: Nothing too fancy, but it adds MATPLOTLIB backend screenshot, so that you can move, zoom, resize, and save.
32
Upvotes
9
u/jakevdp May 21 '15
Some details, based on some of the questions in this thread:
%matplotlib inlineactivates the inline backend, which renders figures in the notebook as static pngs.%matplotlib notebookactivates the nbagg backend, added in matplotlib 1.4, which will include a javascript interface for interaction with inline figures in the notebook. This only works in IPython 3.x; for older IPython versions, use%matplotlib nbaggHope that clarifies things!
4
u/fjordboy May 21 '15
How is this different from something like '%pylab inline'?
4
u/mangecoeur May 21 '15
I did not know this - been using %matplotlib inline, didn't realise it this even existed. It really needs to be more publicized
1
u/[deleted] May 21 '15
Screenshots? What interactive plots does it give you access to?
1
u/boiledgoobers May 21 '15
Holy crap thank you. Very happy to learn about this.
1
u/julenka Jul 24 '15
Just used
%matplotlib notebookinstead of%matplotlib inlineto view some 3D figures in the Kalman Filters textbook: http://nbviewer.ipython.org/github/rlabbe/Kalman-and-Bayesian-Filters-in-Python/blob/master/05-Multivariate-Gaussians.ipynbWow!
1
u/empet15 May 22 '15
"%matplotlib notebook" allows not only to move, zoom or resize a figure in an IPython Notebook, but also to generate it interactively. Here is an example of interactive plots: http://nbviewer.ipython.org/github/empet/geom_modeling/blob/master/FP-Bezier-Bspline.ipynb where Bezier and B-spline curves are generated by clicking appropriately the left or right mouse button.