Get selected data from plotly parallel coordinates plot (in notebook or streamlit app)

I’m building a streamlit app and I would like to have a parallel coordinates plot with a table below it showing the entries that were selected.

This is the sample code for a paralell coordinates plot, within streamlit (but the same applies to a jupyter notebook):

import as px
import streamlit as st

df =
fig = px.parallel_coordinates(df, color="species_id",
                              dimensions=['sepal_width', 'sepal_length', 'petal_width',


if st.button('show selection'):
    tmp_df = df # Do something here to get the selected data

Some posts regarding this topic are using dash to build their platform, that that is not my case. I am using streamlit and don’t fully understand how they are achieving this. The variable “data” from my figure does not update when selecting data, in streamlit or a test notebook, and I am not used to working with callbacks in python o I don’t know what to look for. I would appreciate help understading how to make this work

Mirror question in Stack overflow

Please refer to the answer on stackoverflow.