如何自动绘制时间序列图

时间:2019-06-19 03:50:34

标签: python pandas plotly plotly-python

我有20个时间序列csv文件,每个文件有10列,我正在尝试为其绘制时间序列图。我试图找到一种方法来自动绘制每个csv中每一列的图表

一个csv文件的示例是

date,agr1,agr2,agr3,agr4,agr5,agr6,agr7
01-19,10,10,01,25,52,6,37
02-19,12,15,06,27,54,67,4

我目前可以手动绘制图表

                x=test.Date,
                y=test['Agr1'],
                name = "AGR",
                line = dict(color = '#17BECF'),
                opacity = 0.8)


trace_low = go.Scatter(
                x=test.Date,
                y=test['AGR2'],
                name = "Agr2",
                line = dict(color = '#17BECF'),
                opacity = 0.8)

data = [trace_high,trace_low]

updatemenus = list([
    dict(active=-1,
         buttons=list([   
            dict(label = 'High',
                 method = 'update',
                 args = [{'visible': [True, False]},
                         {'title': 'High'}]),
            dict(label = 'Low',
                 method = 'update',
                 args = [{'visible': [False,True]},
                         {'title': 'Low'}]),
            dict(label = 'Both',
                 method = 'update',
                 args = [{'visible': [True, True]},
                         {'title': 'All'}]),
            dict(label = 'Reset',
                 method = 'update',
                 args = [{'visible': [True, False, True, False]},
                         {'title': 'AGRs'}])
        ]),
    )
])

layout = dict(title='All', showlegend=False,
              updatemenus=updatemenus)

fig = dict(data=data, layout=layout)
py.iplot(fig, filename='update_dropdown')

我希望每个文件都有单独的图表

0 个答案:

没有答案