Search⌘ K
AI Features

Exercise: Adding Customised Sliders

Explore how to create customized interactive sliders in Plotly using Python. Learn to design sliders with specific backgrounds and borders, apply them to time series data, and implement animated sliders to control dynamic bar charts for enhanced data interactivity.

We'll cover the following...

Exercise 1

Using the Hang Seng Index dataset, create a custom date slider that has a white background and a border width of 5 pixels.

Python 3.5
hs = pd.read_csv('/usr/local/csvfiles/^HSI.csv', parse_dates=['Date'])
hs.head()

Solution

  • A trace is created using the go.Scatter() function on line 2 with x and y values taken from the hs DataFrame. The mode parameter is set to lines to create a line chart, and the name parameter specifies the name of the trace for the legend. The marker parameter is used to set the color of the ...