我正在尝试绘制一个时间序列图表,除了时间之外,一切都在工作。出于某种原因,情节是在第一天和之后的情节中绘制,它是以不同的时间和同一时期开始的。通常Plotly应该识别我的时间格式。有谁知道它为什么不能正常工作?
这是我的代码:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x = ['2017-01-01 00:00:00','2017-01-02 06:00:00','2017-01-03 12:00:00','2017-01-04 18:00:00','2017-01-05 00:00:00',
'2017-01-06 06:00:00','2017-01-07 12:00:00','2017-01-08 18:00:00','2017-01-09 00:00:00','2017-01-10 06:00:00',
'2017-01-01 12:00:00','2017-01-02 18:00:00','2017-01-03 00:00:00','2017-01-04 06:00:00','2017-01-05 12:00:00',
'2017-01-06 18:00:00','2017-01-07 00:00:00','2017-01-08 06:00:00','2017-01-09 12:00:00','2017-01-10 18:00:00',
'2017-01-01 00:00:00','2017-01-02 06:00:00','2017-01-03 12:00:00','2017-01-04 18:00:00','2017-01-05 00:00:00',
'2017-01-06 06:00:00','2017-01-07 12:00:00','2017-01-08 18:00:00','2017-01-09 00:00:00','2017-01-10 06:00:00',
'2017-01-01 12:00:00','2017-01-02 18:00:00','2017-01-03 00:00:00','2017-01-04 06:00:00','2017-01-05 12:00:00',
'2017-01-06 18:00:00','2017-01-07 00:00:00','2017-01-08 06:00:00','2017-01-09 12:00:00','2017-01-10 18:00:00']
y1 = np.random.uniform(low=14, high=19.5, size=(40,))
y2 = np.random.uniform(low=14, high=25.0, size=(40,))
trace1 = go.Scatter(
x=x,
y=y1,
name = "Temperature LED",
line = dict(color = '#17BECF'),
opacity = 0.8)
trace2 = go.Scatter(
x=x,
y=y2,
name = "Temperature MDL",
line = dict(color = '#7F7F7F'),
opacity = 0.8)
data = [trace1,trace2]
layout = dict(
title='Temperature LED vs MDL',
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label='1d',
step='day',
stepmode='backward'),
dict(count=6,
label='6d',
step='day',
stepmode='backward'),
dict(step='all')
])
),
rangeslider=dict(),
type='date'
)
)
fig = dict(data=data, layout=layout)
py.plot(fig, filename="Time Series with Rangeslider")