Open In App
Related Articles

How to make sliders in Plotly?

Improve Article
Improve
Save Article
Save
Like Article
Like

A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library. 

Simple Slider Control

In plotly, a slider is a Tkinter object with which a user can set the values by moving an indicator. A slider can be vertically and horizontally arranged. In plotly, the slider can be formed by using the Scale method(). 

Example 1:

Python3




import plotly.graph_objects as px
import plotly.express as go
import numpy as np
  
df = go.data.tips()
  
x = df['total_bill']
y = df['day']
  
plot = px.Figure(data=[px.Scatter(
    x=x,
    y=y,
    mode='lines',)
])
  
plot.update_layout(
    xaxis=dict(
        rangeselector=dict(
            buttons=list([
                dict(count=1,
                     step="day",
                     stepmode="backward"),
            ])
        ),
        rangeslider=dict(
            visible=True
        ),
    )
)
  
plot.show()


Output:

Example 2:

Python3




import plotly.express as px
  
df = px.data.tips()
  
fig = px.scatter(df, x="total_bill", y="tip"
                 animation_frame="day",
                 color="sex",)
  
fig["layout"].pop("updatemenus")
fig.show()


Output:
 

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 01 Oct, 2020
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials