# Pre-defined range buttons

**URL:** <https://community.plotly.com/t/pre-defined-range-buttons/39267>\
**Category:** 📊 Plotly Python\
**Created:** [May 12, 2020, 1:36am UTC](https://community.plotly.com/t/pre-defined-range-buttons/39267 "2020-05-12T01:36:12Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [May 12, 2020, 8:02am UTC](https://community.plotly.com/t/pre-defined-range-buttons/39267/3 "2020-05-12T08:02:18Z")

</div>

In fact a simpler syntax is to pass directly `xaxis.range` in the `args` as in

```auto
import plotly.graph_objects as go

import pandas as pd

# Load data
df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
df.columns = [col.replace("AAPL.", "") for col in df.columns]

# Create figure
fig = go.Figure()

fig.add_trace(
    go.Scatter(x=list(df.Date), y=list(df.High)))

# Set title
fig.update_layout(
    title_text="Time series with range slider and selectors"
)

# Add range slider
fig.update_layout(
    xaxis=dict(
       
        rangeslider=dict(
            visible=True
        ),
        type="date",
        range=('2015-04-01', '2017-01-01')
    )
)
fig.update_layout(
    updatemenus=[
        dict(
            type="buttons",
            buttons=[
                dict(label="Custom",
                     method="relayout",
                     args=["xaxis.range", ('2015-07-01', '2015-09-01'),]),]
        )]
)
fig.show()

```

---

_[View the full topic](https://community.plotly.com/t/pre-defined-range-buttons/39267)._
