2

Is there a way to highlight all points with attribute on click?

I am working within a Streamlit framework, so Dash solutions won't work.

Similar to this post: Highlight all values from a group on hover

In the below, example, I'm looking to highlight all items from the same group after clicking.

import pandas as pd
import plotly.express as px

df = pd.DataFrame(dict(
    x=[4, 5, 1, 3, 2, 2],
    y=[3, 1, 7, 9, 8, 3],
    group=[0, 0, 0, 1, 1, 1],
    value=[1, 2, 3, 4, 5, 6],
    hover=['s1', 's2', 's3', 's4', 's5', 's6']
))

fig = px.scatter(
    df,
    y='y',
    x='x',
    color='group',
    hover_name='hover',
)
fig.show()
Derek O
  • 16,770
  • 4
  • 24
  • 43
Oliver
  • 281
  • 3
  • 14
  • as far as I know, this isn't possible in plotly. one partial solution might be to create a dropdown that highlights all markers in the selected group – if you're interested i could write up such a solution – Derek O Jan 31 '23 at 01:55

0 Answers0