I have two sets of data points with the same datetime values. I am trying to plot the two together overtime, and add a slider to filter down the dates to specific ranges (as was done in https://plot.ly/python/range-slider/#basic-range-slider-and-range-selectors).
While it seems like the slider was created properly (i simply used the same code as suggested in the tutorial as a first try), the dates there are around 2000-2004, while my date ranges are 2016-2019. I canβt seem to see my data at all, although it appears in the legend.
This was my setup:
df looks like:
index date time_spent1 time_spent2
0 2016-01-02 3.22 6.56
1 2016-01-03 1.74 7.10
2 2016-01-04 0.53 5.67
3 2016-01-05 2.67 7.50
The code:
import pandas as pd
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Scatter(
x = list(df.date),
y = list(df.time_spent2),
mode = 'lines+markers',
name = 'Time2 [hrs]',
marker = dict(
color = 'blue'
)
)
trace2 = go.Scatter(
x = list(df.date),
y = list(df.time_spent1),
mode = 'lines+markers',
name = 'Time1 [hrs]',
marker = dict(
color = 'orange'
)
)
data = [trace1, trace2]
# slider set up:
layout = dict(
title='Time series with range slider and selectors',
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(count=1,
label='YTD',
step='year',
stepmode='todate'),
dict(count=1,
label='1y',
step='year',
stepmode='backward'),
dict(step='all')
])
),
rangeslider=dict(
visible = True
),
type='date'
)
)
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='temp1')
Suggestions how to fix this?