Skip to main content
 首页 » 编程设计

python之用于控制 Jupyter 仪表板的多个单元格的小部件

2025年05月04日8itcoder

我正在尝试构建一个包含许多图表和表格的 jupyter 仪表板。理想情况下,所有图表和表格将同时相应地更改为相同的小部件值。

我可以创建一个函数来处理所有图表和表格的创建并显示它们,但随后我将限制布局,而这正是 jupyter 仪表板所擅长的。

def create_dashboard(x, y, z): 
    # make first plot using x 
    ... 
    # make second plot using x, y 
    ... 
    # draw table from dataframe using x, y, z 
    ... 
 
interact(create_dashboard, x, y ,z) 

这可以工作,但非常有限。此外,即使您不更改将修改输出的变量,您也需要始终生成所有图表和表格(很多很多)。此外,所有这些都按顺序显示在 ipython 单元格中,但在创建仪表板时无法移动它们。

有没有什么方法可以在单个单元格中绘制plot using x、plot using y 和table using x, y, z,以及然后创建一个控制所有三个单元格的小部件?有点像

output[1] 
# plot using x 
 
output[2] 
# plot using x, y 
 
output[3] 
# table from dataframe using x, y, z 
 
output[4] 
interact(x, y, z) 
# show the widget only here 

希望这是清楚的。如果不是,我很乐意提供更多信息。

谢谢!

请您参考如下方法:

我会尝试使用 Plotly for python https://plot.ly/python/create-online-dashboard/

让我们知道进展如何!