I can select datapoints in my plot, get theire indexes, and filter a dataframe based on those indexes. So far so good.
While i select datapoints, they show as highlighted. As soon as i select them, the plot is rerenderd loosing the selected items. So after selection i have the info i selected in the dataframe below, but i am not seeing my selection anymore.
This is my crrent code:
with st.expander("TSNE Parameter", expanded=False): #copydf is a dataframe copydf = st.session_state.dataUpdated.copy() data2D = tsne(copydf, perplexity, learning_rate) st.session_state.plot = renderplot(data2D) fig = st.session_state.plot selected_data = plotly_events(fig, click_event=True, select_event=True, key="pe_selected") # show selected data in widget if selected_data is not None: # extrahiere die x- und y-Werte für die ausgewählten Punkte x_selected = [i['x'] for i in selected_data] y_selected = [i['y'] for i in selected_data] # find index of selected datapoints idx_selected =  for x, y in zip(x_selected, y_selected): selectedRows = data2D[(data2D['tsne-2d-one'] == x) & (data2D['tsne-2d-two'] == y)] idx =selectedRows.index.astype(int) idx_selected.append(idx) #Extract columns for new dataframe df_selected = copydf.loc[idx_selected, ['SAG-Nummer', 'TicketID', 'Text', 'Tokens','Gelöst']] if not df_selected.empty: st.dataframe(df_selected)
What i want is to keep the selected datapoints in the plot. I gues i need to prevent streamlit rendering the component again.
the screenshot shows my app after i selected those 2 datapoints. As you can see they are not selected in the plot but “extracted” into the dataframe