Slider in scatter plot with Plotly express

Hello,

I was trying to create a scatter plot with streamlit and plotly express, but i can’t put a slider on the chart. Somebody can help me?

fig.update_layout(
sliders=[
{
“steps”: [
{
“args”: [[str(year)], {“frame”: {“duration”: 500, “redraw”: True}, “mode”: “immediate”}],
“label”: str(year),
“method”: “animate”
} for year in years
],
“currentvalue”: {“prefix”: "year: "},
“pad”: {“t”: 50},
}
]
)

Hey,
You should share your code (in formatted way). Are you looking for something like this ?

# Sample data
df = px.data.gapminder()

# Create a Plotly Express figure
fig = px.scatter(
    df,
    x="gdpPercap",
    y="lifeExp",
    animation_frame="year",
    animation_group="country",
    size="pop",
    color="continent",
    hover_name="country",
    log_x=True,
    size_max=55,
    title="Gapminder Data Over Time",
)

# Update layout for better visuals
fig.update_layout(
    sliders=[{
        "currentvalue": {"prefix": "Year: "},
    }]
)

# Streamlit app
st.plotly_chart(fig)