我看了一些教程,包括official docs,似乎每个人都喜欢Output
afigure
例如:
@app.callback(
Output('graph-with-slider', 'figure'),
Input('year-slider', 'value'))
def update_figure(selected_year):
filtered_df = df[df.year == selected_year]
fig = px.scatter(filtered_df, x="gdpPercap", y="lifeExp",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55)
fig.update_layout(transition_duration=500)
return fig
为什么不只是将数据输出到图的data
字段
可能吗
您可以使用只返回数据、布局等的回调
但返回的数据通常没有这样冗长,更容易理解,也不容易出错
相关问题 更多 >
编程相关推荐