iPython: Manipulate-like command

前端 未结 2 873
萌比男神i
萌比男神i 2020-12-24 13:24

In Wolfram Mathematica, I can interactively modify the value of a parameter by using the Manipulate[] command.

For example, Manipulate[n, {n, 1, 2

2条回答
  •  盖世英雄少女心
    2020-12-24 14:26

    I am not sure whether this would satisfy all your needs as it is still experimental, but seems to do what you asked for - look at static interactive widgets by Jake VanderPlas.

    What I did to get running was the following:

    Get the source and install:

    git clone https://github.com/jakevdp/ipywidgets
    pip install ./ipywidgets
    

    start an ipython notebook and experiment with the notebook example.ipynb in the ipywidgets directory

    There's another type of interactive visualisation, where panning, zoom and meta-data are available (possibly more). It is by the same author and reported in his blog D3 Plugins: Truly Interactive Matplotlib In Your Browser.

    There are also nice docs: MPLD3: Bringing Matplotlib to the Browser

    To experiment with it I did more or less the same:

    git clone https://github.com/jakevdp/mpld3
    pip install ./mpld3/
    

    One can now run the create_example.py script, or even better, start an ipython notebook and play with the provided mpld3/notebooks/mpld3_demo.ipynb as well as with the attractive examples of mpld3_plugins posted in the blog.

    It may be worth noting that I am using the Anaconda distro of python, which includes Jinja2; as far as I know Jinja2 is a requirement for mpld3.

    I do agree that an @interact decorator a la sage would be nice.

提交回复
热议问题