Plotly click events in streamlit

I am using streamlit library for simple dashboard. Is it possible to use plotly click events in streamlit. Is there any other way to get click events on bar chart, scatter plots, etc, in streamlit?

The code that i tried :

import plotly.graph_objects as go
import streamlit as st
import numpy as np

def update_point(trace, points, state):
print(trace, points, state)

def main():
x = np.random.rand(10)
y = np.random.rand(10)
f = go.FigureWidget([go.Scatter(x=x, y=y)])
s =[0]


if name == ‘main’:


Hi @sandesh_more

That kind of interactivity is currently not supported. See

Thanks for the reply.

Hi, I see this thread was created in 2019, I just wanted to know if there have been updates on this matter? i.e. using go.FigureWidget and get outputs from graph selection?

1 Like

New functionality!


How can I return the min, max X values from a selection?

1 Like

Does this support the use_container_width argument when displaying the figure?

1 Like

Hi, I have added this event somewhere in between my Streamlit dashboard for a specific visual. The code would not run beyond that specific visual in the first go until I click on it and create a streamlit event, only then the rest of the visuals would get displayed. Can anyone help with it?

Does it support



Yes, st.plotly_chart contains a boolean use_container_width parameter:

1 Like

This changes the theme of any plotly chart to black and white. Any thoughts on how to solve this?


@R_D , can you explain your problem more? Maybe post some screenshots and some code?

Hey, ran into the same issue and figured out what’s wrong. Looks like the recent streamlit update is trying to managing plotly’s color. As a result all the color will show up as black unless you use streamlit’s plotly_chart method.

Here is the thread talking about the exact same issue.

Hopefully streamlit will fix this. In the mean time if you explicit set plotly line color (might have to use plotly’s graph_object interface) the color will appear correctly.

1 Like

Hi @Kevin1 ,

Thanks for pointing out this out. I hadn’t noticed this and I wish I had earlier.

If you wish to change the colors to the plotly colors instead of the black,

you can put this in your script:

import as pio
pio.templates.default = "plotly"

You can test this out by changing the colors in the underlying script to whatever. Right now in the script, they are streamlit colors.

import as pio
import streamlit as st
import as px

pio.templates.default = "plotly"

df =
fig = px.scatter(
    title="streamlit colors",
1 Like

Hi, This discussion was very helpful! Thanks all!
I have a quick question, I am using Plotly-events for capturing user selection from a bar chart but I want to reset this selection to null when my streamlit dashboard reloads. How can I make this happen? Thanks.

1 Like

Hi, any update regarding getting the clicked point from a plotly chart?
The work around of using plotly-events doesn’t work well after streamlit 1.12.0.


I am also facing problems regarding this, did you find any fixes?