如何在网页中嵌入交互式matplotlib图 [英] How to embed an interactive matplotlib plot in a webpage
问题描述
我一直在研究如何嵌入交互式matplotlib小部件(例如这样的小部件: http://matplotlib.org/examples /widgets/slider_demo.html ).最终目的是制作一个教育性页面.
I have been searching how to embed an interactive matplotlib widget (like this one: http://matplotlib.org/examples/widgets/slider_demo.html) in a webpage. The final aim is to make an educational page.
我希望我不要重复这个问题.谷歌发现的始终是如何将图以图像格式嵌入为静态照片.
I hope I am not duplicating the question. What google finds is always how to embed the plot as a still-shot, in an image format.
我以为我可以使用 ipython notebook 或 plotly 或 gjango 来做一些事情.但是我很困惑.
I thought I can do something with ipython notebook or plotly or gjango. But I got confused.
吸引人的情节完全有可能吗? 感谢您的指导,我应该为之思考和努力.
Is it possible at all for intractive plots? I appreciate your guides to which direction I should think and work on.
谢谢.
推荐答案
在2015年夏天,我面临着一个类似的任务:嵌入交互式小部件,这些小部件在移动滑块时会更改其基础数据.这与交互式IPython小部件在本地计算机上运行时是交互式的.可以找到我想要的示例 jakevdp的博客
In summer 2015, I'm facing a similar task: embed interactive widgets that change their underlying data when the slider is moved. This is very similar to interactive IPython widgets which are interactive when run on a local machine. Examples of what I want can be found jakevdp's blog.
总结到目前为止已完成的工作:
To summarize work done so far:
- ipywidgets-static 将交互式IPython小部件转换为静态HTML.但是,该库不再维护.开发已移至 ipython/ipywidgets .
- IPython正在开发 ipython/ipywidgets .他们有一个 Github问题,以使这些小部件静态化并嵌入其中一个独立的HTML文件.
- HoloViews 提供了一些可以嵌入到静态HTML文件中的交互式滑块选项(使用IPython的nbconvert )
- 散景依赖于交互式滑块的图 plot.ly 不支持滑块/等.基于此博客文章,我相信这是正确的. /li>
- mpld3 在matplotlib和d3之间转换.我相信该库支持平移和缩放,而不支持滑块/交互性.这是相关的Github问题
- ipywidgets-static converts interactive IPython widgets to static HTML. However, this library is no longer maintained. Development has moved to ipython/ipywidgets.
- IPython is working on ipython/ipywidgets. They have a Github issue to make these widgets static and to be embedded in a standalone HTML file.
- HoloViews provides some interactive slider options that can be embedded in a static HTML file (using IPython's nbconvert)
- Bokeh plots that rely on interactive sliders require a server.
- plot.ly doesn't support sliders/etc. I believe this is true based off this blog post.
- mpld3 converts between matplotlib and d3. I believe this library supports panning and zooming, not sliders/interactivity. Here's a related Github issue
还有一篇博客文章,标题为"浏览器:它来了!".这篇文章的日期为2014-3-31.
There's also blog post titled "Scientific Python in the browser: it's coming!". This post was dated 2014-3-31.
对我来说,两个最吸引人的选项是ipywidgets和HoloViews,但是我很期待IPython提供静态交互式小部件.我希望能在不到2020年的5年内(以及在2017年的2年内)迅速获得对静态交互式窗口小部件的坚实支持.
For me, the two most attractive options are ipywidgets and HoloViews but I'm looking forward to when IPython provides static interactive widgets. I expect to see solid support for static interactive widgets quickly and in less that 5 years/2020 (and in 2 years/2017?).
这篇关于如何在网页中嵌入交互式matplotlib图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!