Rangeslider buttons for numerical not date data

How can I implement the rangeslider buttons for numerical data, e.g. 1, 2, 3, … 10, instead of date data on the x-axis?

It all works well here with date data

import plotly.express as px
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_speed_laurel_nebraska.csv')

fig = px.line(df, x='Time', y='10 Min Sampled Avg', title='10 Min Std Dev')

# Add range slider
fig.update_layout(
    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.show()

but not here with numerical data (actually I would like have seconds on the x-axis). Just changed type="data" to type="linear"? The data that I used are here https://www.dropbox.com/s/u2dbj0tcqz8hfhi/test_excel_import_1.xlsx?dl=0

import plotly.graph_objs as go
import pandas as pd

#df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_speed_laurel_nebraska.csv')
df = pd.read_excel('/Users/Jakob/Documents/python_notebooks/data/test_excel_import_1.xlsx')

fig = go.Figure([
    
    go.Scatter(
        name='Measurement 1',
        x=df['Time'],
        y=df['10 Min Sampled Avg'],
        mode='markers+lines',
        line=dict(color='rgba(255, 153, 255, 1)', width=1),
        marker=dict(color='red', size=5),
        showlegend=True
    ),
    go.Scatter(
        name='Upper Bound',
        x=df['Time'],
        y=df['10 Min Sampled Avg']+df['10 Min Std Dev'],
        mode='lines',
        marker=dict(color='orange'),
        line=dict(width=0),
        showlegend=False
    ),
    go.Scatter(
        name='Lower Bound',
        x=df['Time'],
        y=df['10 Min Sampled Avg']-df['10 Min Std Dev'],
        marker=dict(color='orange'),
        line=dict(width=0),
        mode='lines',
        fillcolor='rgba(255, 153, 255, 0.1)',
        fill='tonexty',
        showlegend=False
    ),
    
    
])

# Add range slider
fig.update_layout(
    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="linear"
    )
)

#fig.update_xaxes(range=[5, 10])
fig.update_layout(
    yaxis_title='Wind speed (m/s)',
    title='Continuous, variable value error bars',
    hovermode="x", legend_traceorder='reversed', template='simple_white',
    legend=dict(bordercolor='magenta', borderwidth=2, itemclick='toggle', itemsizing='constant', x=0.8)
)
fig.show()

Hi @windrose , I also want rangeselector for numerical data , did you find any solution ?

Hi @saksham7778 you can use rangeslider also with numerical data, e.g. seconds, no problem. I don’t remember what my exact problem was back then.