Quantcast
Channel: ЁЯОЫя╕П Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271
тЖз

Highlight Group of Points on Hover

$
0
0

Hi -

IтАЩm trying to do something similar to this, only with Plotly.py. In other words, IтАЩd like to create a scatterplot with grouped points where all points within the group are highlighted (and/or enlarged) and display a tooltip on hover.

Is there an easy way to do this with Plotly.py? And if not, is there a hard way to do it? :slightly_smiling_face:

Toy example here (minus the desired hover behavior, obviously):

import plotly.io as pio

family = ['Brown', 'Brown', 'Brown', 'Smith', 'Smith', 'Smith', 'Jones', 'Jones', 'Jones', 'Lee', 'Lee', 'Lee']
subject = ['Moe','Larry','Curly','Moe','Larry','Curly','Moe','Larry','Curly','Moe','Larry','Curly']
score = [1,6,2,8,3,9,4,5,1,5,2,8]

data = [dict(
  type = 'scatter',
  x = subject,
  y = score,
  mode = 'markers',
  transforms = [dict(
    type = 'groupby',
    groups = family,
    styles = [
        dict(target = 'Smith', value = dict(marker = dict(color = 'blue'))),
        dict(target = 'Brown', value = dict(marker = dict(color = 'red'))),
        dict(target = 'Jones', value = dict(marker = dict(color = 'black'))),
        dict(target = 'Lee', value = dict(marker = dict(color = 'green')))
    ]
  )]
)]

fig_dict = dict(data=data)
pio.show(fig_dict, validate=False)

Thanks for your help!

2 posts - 1 participant

Read full topic

тЖз

Viewing all articles
Browse latest Browse all 6271

Trending Articles