Animated graphs in ipython notebook

前端 未结 8 788
失恋的感觉
失恋的感觉 2020-12-30 02:01

Is there a way of creating animated graphs. For example showing the same graph, with different parameters.

For example is SAGE notebook, one can write:



        
8条回答
  •  萌比男神i
    2020-12-30 02:49

    If you use IPython notebook, v2.0 and above support interactive widgets. You can find a good example notebook here (n.b. you need to download and run from your own machine to see the sliders).

    It essentially boils down to importing interact, and then passing it a function, along with ranges for the paramters. e.g., from the second link:

    In [8]:
    def pltsin(f, a):
        plot(x,a*sin(2*pi*x*f))
        ylim(-10,10)
    In [9]:
    interact(pltsin, f=(1,10,0.1), a=(1,10,1));
    

    This will produce a plot with two sliders, for f and a.

提交回复
热议问题