且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在网页中嵌入交互式matplotlib图

更新时间:2023-12-06 15:35:52

在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 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?).