[IPython-User] Notebook: replot from axis object in subsequent cells
Sat Sep 15 06:16:00 CDT 2012
First, I suggest you use `subplots` with s , which return both the figure and the axes of each subplot.
And is a little more convenient than subplot. You could learn more with `subplots?`
You can then show the current sate of the figure at anytime with display(figure)
f , ax = subplots()
Or returning `f` at the end of you cell which will display it as output of the cell.
As you are writing a tutorial, just keep in mind that there is a slight difference between ending a cell with `display(f)` or `f`
as the first only display and the second return the figure.
Of course you can do the same with subplot (without s) as long as you use figure() and assign it to f before plotting.
`display` function is specific to IPython, but difference between figures and axes are more a matplotlib issues in which i'm not an expert.
We would be happy to see what are the use people make of the notebooks, so don't hesitate to share yours.
May I suggest you to have a look at nbconvert one of IPython organization repo on github, and also
nbviewer that might be useful for you , also Fernando did write a little blog post on how to embed notebook static view on blogs.
Le 15 sept. 2012 à 09:17, Michael Waskom a écrit :
> I'm working on converting some tutorials over from MATLAB into the Notebook. In these tutorials, frequently there will be some code to generate a plot, commentary on the plot, and then several small changes and replots (e.g. adding things in steps, changing the view in 3D plots, etc.)
> Is there a way (using the matplotlib object-oriented interface) to replot an axis object in a subsequent cell, thus avoiding rewriting all of the common plotting code? In other words something like:
> In : ax = subplot(111); ax.plot(foo);
> In : replot(ax); ax.plot(bar)
> Obviously in this toy example it doesn't save much, but for more complicated plots it could make things much more clean.
> IPython-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User