问题
I have an IPython Notebook that is using Pandas to back-test a rule-based trading system.
I have a function that accepts various scalars and functions as parameters and outputs a stats pack as some tables and a couple of plots.
For automation, I want to be able to format this nicely into a "page" and then call the function in a loop while varying the inputs and have it output a number of pages for comparison, all from a single notebook cell.
The approach I am taking is to create IpyTables and then call _repr_html_(), building up the HTML output along the way so that I can eventually return it from the function that runs the loop.
How can I capture the output of the plots this way - matplotlib subplot objects don't seem to implement _repr_html_()?
Feel free to suggest another approach entirely that you think might equally solve the problem.
TIA
回答1:
Ok, if you go that route, this answer stackoverflow.com/a/5314808/243434 on how to capture >matplotlib figures as inline PNGs may help – @crewbum
To prevent duplication of plots, try running with pylab disabled (double-check your config >files and the command line). – @crewbum
--> this last requires a restart of the notebook: ipython notebook --pylab (NB no inline)
来源:https://stackoverflow.com/questions/14580684/how-to-grab-matplotlib-plot-as-html-in-ipython-notebook