Show Sidebar Hide Sidebar

Slider Widget in Python

Interacting with Plotly FigureWidgets using Sliders

New to Plotly?

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!

Using a Single Slider to Set the Range

In [2]:
import plotly.graph_objs as go
import plotly.offline as py
import plotly

from ipywidgets import interactive, HBox, VBox, widgets, interact


# load fig
fig = plotly.plotly.get_figure("")

# find the range of the slider.
xmin, xmax = fig['layout']['xaxis']['range']

# create FigureWidget from fig
f = go.FigureWidget(, layout=fig.layout)

slider = widgets.FloatRangeSlider(
    step=(xmax - xmin) / 1000.0,
slider.layout.width = '800px'

# our function that will modify the xaxis range
def update_range(y):
    f.layout.xaxis.range = [y[0], y[1]]

# display the FigureWidget and slider with center justification
vb = VBox((f, interactive(update_range, y=slider)))
vb.layout.align_items = 'center'