小编Ber*_*ter的帖子

在交互式ipywidgets中排列小部件

我有使用ipywidgets的交互式图形代码;但不确定如何在小部件中的交互式函数中延迟每个变量。默认布局为垂直。但我想将它们水平排列。

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.style.use('seaborn')
%config InlineBackend.figure_format = 'svg'
from ipywidgets import interactive,interact
#function to plot the different curves
def plot_function(u=1,v=2,w=3,x=4,y=5,z=6):
    time=np.arange(0,1,0.01)
    df=pd.DataFrame({"Y1":np.sin(time*u*2*np.pi),"y2":np.sin(time*v*2*np.pi),"y3":np.sin(time*w*2*np.pi),
                    "y4":np.sin(time*x*2*np.pi),"y5":np.sin(time*y*2*np.pi),"y6":np.sin(time*z*2*np.pi)})
    df.plot()
widget=interactive(plot_function,u=1,v=2,w=3,x=4,y=5,z=6)
widget
Run Code Online (Sandbox Code Playgroud)

输出量

interactive python-3.x jupyter-notebook ipywidgets

4
推荐指数
1
解决办法
1127
查看次数