gpt4 book ai didi

python - 如何在 ipython 笔记本中将 matplotlib 图抓取为 html?

转载 作者:行者123 更新时间:2023-11-28 18:49:54 24 4
gpt4 key购买 nike

我有一个 IPython Notebook,它使用 Pandas 对基于规则的交易系统进行回测。

我有一个函数,它接受各种标量和函数作为参数,并输出一个统计数据包作为一些表格和几个图表。

对于自动化,我希望能够将其很好地格式化为一个“页面”,然后在循环中调用该函数,同时改变输入并让它输出多个页面以进行比较,所有这些都来自一个笔记本单元格。

我采用的方法是创建 IpyTables,然后调用 _repr_html_(),一路构建 HTML 输出,以便我最终可以从运行循环的函数中返回它。

如何以这种方式捕获绘图的输出 - matplotlib 子图对象似乎没有实现 _repr_html_()

请随意提出您认为同样可以解决问题的完全不同的方法。

TIA

最佳答案

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

--> 最后需要重启笔记本:ipython notebook --pylab (NB no inline)

关于python - 如何在 ipython 笔记本中将 matplotlib 图抓取为 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14580684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com