I'd like a rangeslider on my plot but I don't want to initially view all the data but instead just view e.g. the YTD. I thought I could do that with the range argument but setting that just compresses the view in the rangeslider axis but you still see all the data. Is this a bug? It's certainly not behaving as I would have expected and I can't really see a use-case for the present behaviour:

Repro notebook @ https://anaconda.org/dhirschfeld/plotlybug/notebook
...so when you drag the rangeslider back it shows a range that wasn't even in your input data:

What I'm after is the below view being displayed by default i.e. as if I had already clicked the YTD button before the chart was initially rendered:

Hi there,
https://plot.ly/python/reference/#layout-xaxis-rangeslider-range
That attribute was created to set the range of the rangeslider along the xaxis so the above result is the expected result.
Are you trying to set the range of your plot? In that case you should use the x-axis range argument:
https://plot.ly/python/reference/#layout-xaxis-range
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.plotly as py
dates = pd.date_range('01-Jan-2010', pd.datetime.now().date(), freq='D')
df = pd.DataFrame(100 + np.random.randn(dates.size).cumsum(), dates, columns=['AAPL'])
trace = go.Scatter(x=df.index, y=df.AAPL)
data = [trace]
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(),
type='date'
)
)
fig = dict(data=data, layout=layout)
py.iplot(fig)
initial_range = [
'2016-01-01', '2017-09-01'
]
fig['layout']['xaxis'].update(range=initial_range)
py.iplot(fig)
this will result in something like:

Yep, thanks @cldougl!
Most helpful comment
Hi there,
https://plot.ly/python/reference/#layout-xaxis-rangeslider-range
That attribute was created to set the range of the rangeslider along the xaxis so the above result is the expected result.
Are you trying to set the range of your plot? In that case you should use the x-axis range argument:
https://plot.ly/python/reference/#layout-xaxis-range
this will result in something like:
