我不明白为什么这段代码不起作用。数据是虚构的,我只希望能够使用plotly进行时间序列可视化。
这个模块曾经在Kaggle内核中为我工作过:
https://www.kaggle.com/aubertsigouin/organizing-macrohistorical-datasets/data
奇怪的是,我无法使其再次运行。它说:«AttributeError:模块'plotly'没有属性'plotly'»。
有小费吗 ?
import plotly
import plotly.graph_objs as go
from plotly import tools
from plotly.offline import init_notebook_mode, plot, iplot
init_notebook_mode()
import pandas as pd
import numpy as np
data = []
array_of_time = pd.to_datetime(np.arange('2013-01-01', '2013-03-01', dtype='datetime64[M]'))
raw_data = [[20,29], [30,33]]
trace_1 = go.Scatter(
x=array_of_time,
y=raw_data[0],
name = 'data_1',
line = dict(color = '#aeb9ba'),
opacity = 0.8
)
trace_2 = go.Scatter(
x=array_of_time,
y=raw_data[1],
name = 'data_2',
line = dict(color = '#ffd800'),
opacity = 0.8
)
data.append(trace_1)
data.append(trace_2)
layout = dict(
title = 'Exemple de titre',
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(
count=1,
label='1m',
step='month',
stepmode='backward'
),
dict(
count=6,
label='6m',
step='month',
stepmode='backward'
),
dict(
step='all'
)
]
)
),
rangeslider=dict(),
type='date'
)
)
fig = dict(data=data, layout=layout)
iplot(fig, filename = 'graph_1.html')
慕哥6287543
森栏
相关分类