Interactive plot: Get which point a user clicked

Given there is a scatter plot, would it be possible to make user select the data point on the plot in order to display contents depending on which data point user chose?

Although plotly offeres similar functionality, it only allows me to change the text to display when the cursor is hovered on some point. But I want to display other data like image and data frame too. The explanation does not need to be on the plot like plotly.

The reproducible code for the image above.

data = load_iris()
df = pd.DataFrame(, columns=data.feature_names)
fig = px.scatter(
    data_frame=df, x="sepal length (cm)", y="sepal width (cm)", title="Sample Data",

# I want to show some contents depending ot what user select on the figure.
st.write("Explanation about the data point user chose.")

As long as similar functionality can be implemented, I don’t care which plot library to use e.g. matplotlib.

Any suggestion or help will be very appreciated. Thank you in advance.


  • st version: 0.81.0
  • Python version: 3.9
  • MacOS with Safari and Chrome

Hi, I have the exact same problem, Were you able to figure this out ?

Hi @Vineeth_Reddy ,

You can use this component for your usecase


1 Like