Python 绘图交互式条形图不';t在显示新跟踪之前,请不要删除以前的跟踪
我正在尝试创建一个交互式plotly条形图Python 绘图交互式条形图不';t在显示新跟踪之前,请不要删除以前的跟踪,python,plotly-python,Python,Plotly Python,我正在尝试创建一个交互式plotly条形图 select_feat = widgets.Dropdown(options=['overall_rating', 'potential'], description='Feature') fig_1 = go.FigureWidget() def response_1(feature): x = player_info.groupby(['player_name'])[feature].mean().nlargest(5) val
select_feat = widgets.Dropdown(options=['overall_rating', 'potential'], description='Feature')
fig_1 = go.FigureWidget()
def response_1(feature):
x = player_info.groupby(['player_name'])[feature].mean().nlargest(5)
val = list(x.values)
lab = list(x.index.values)
fig_1.add_trace(go.Bar(x=lab, y=val))
fig_1.update_layout(title='Top five playes by average')
VBox((fig_1, interactive(response_1, feature=select_feat)))
当我执行代码时,为了整体的_评级。当选择选项潜在时。梅西、罗纳尔多和伊涅斯塔在综合排名和潜力方面都位居榜首。所以它为他们展示了两个小节。
因此,我可以对只显示选定的功能相关跟踪做些什么
我正在jupyter笔记本电脑中使用plotly offline。通过将添加跟踪替换为更新跟踪,并在FigureWidget()中添加(data=[{'type':'bar'),我解决了这个问题