Range slider doesn't show up

Hi,

I run the following code I found on github:

import numpy as np
import pandas as pd

import plotly.graph_objs as go
import plotly.plotly as py
from plotly.offline import plot
 
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)


plot(fig)

Here is the result I get:

As you can see there is nowhere the range slider. Any clue why is this the case?

Did you try rangeslider = True?

Do you mean to replace rangeslider=dict() with rangeslider=True?

Yes I did and I get the following error:

ValueError: 
    Invalid value of type 'builtins.bool' received for the 'rangeslider' property of layout.xaxis
        Received value: True

    The 'rangeslider' property is an instance of Rangeslider
    that may be specified as:
      - An instance of plotly.graph_objs.layout.xaxis.Rangeslider
      - A dict of string/value properties that will be passed
        to the Rangeslider constructor

Hey @mr.t

Try:

layout = go.Layout(
    xaxis = dict(
        rangeslider = dict(
            visible = True
        )
    )
)

Here is the full attributes https://plot.ly/python/reference/#layout-xaxis-rangeslider

@bcd thanks! thought that visible attribute is by default set to True as mentioned in the documentation

No worries! Could you confirm what plotly version you’re using?

plotly 3.0.0 installed with pip