How to grab matplotlib plot as html in ipython notebook?

两盒软妹~` 提交于 2019-12-12 13:16:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!