ipywidgets与plotly交互不会生成绘图

2024-04-27 01:39:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用谷歌搜索引擎。我正在尝试将交互式小部件与python结合使用。 用于生成简单绘图的函数仅适用于:

from ipywidgets import interactive
import plotly.express as px

def g(x,y):
    fig = px.scatter(x=df[x], y=df[y])
    fig.show()

g('a','b')

output

但是,当我尝试使用交互式小部件时,输出附带小部件,但没有绘图:

def g(x,y):
    fig = px.scatter(x=df[x], y=df[y])
    fig.show()

interactive_plot = interactive(g, x=columns, y=columns)
interactive_plot

interactive output

当我将库更改回matplotlib时,它工作得很好,就像这个question。但是,我不得不使用plotly,因为它们的“悬停”功能非常方便


Tags: columnsimport绘图dfoutputplot部件def