首页 > 解决方案 > 将 Python 代码图转换为 Dash 和 Plotly 图

问题描述

我有这个代码:

fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(14, 8))

for xcol, ax in zip(dff.columns.values, axes):
    dff.plot(kind='scatter', x=xcol, y=selected_dropdown_value, ax=ax, alpha=0.5, 
    color='r')

我需要将其转换为 Plotly 和 Dash 可以使用的东西,如本例所示:https ://plot.ly/pandas/line-and-scatter/ 。我怎样才能做到这一点?数据框是根据用户在下拉列表中选择的值创建的,然后根据 col_to_plot.. 列绘制所有列。

更新:数据如下:

country   year  type color col_to_plot_1   col_to_plot_2  ... 

France   1991   t1    blue      200              3.5
Belgium  1992   t2    black      30              100.5
...      ...    ..     ...       ...               ...

标签: python-3.xpandasplotly

解决方案


推荐阅读