Black Lives Matter. Please consider donating to Black Girls Code today.

Box point hover

If I use boxpoints='all' then it seems like I should be able to hover over the points and see the text for each point. Specifically in dash, that doesn’t seem to work.

Here’s an example:

import dash
import dash_html_components as html
import dash_core_components as dcc
from plotly.tools import make_subplots
import numpy as np
import pandas as pd

d1=pd.DataFrame(np.random.choice(list('ABC'),p=[.45,.45,.1],size=[100,5]))
d2=pd.DataFrame(np.random.normal(size=[100,5]))

data=[]
for i,x in d1.iteritems():
    data.append(dict(y=d2[i],x=x,name=f'series {i}',text=[f'point {j}' for j in x.index],
                boxpoints='all',hoverinfo='text+name',type='box'))
fig={'data':data,
     'layout':{'hovermode':'closest','boxmode':'group'}}

app = dash.Dash()

app.layout = html.Div([
    dcc.Graph(id='graph1',figure=fig)
    ]
)

app.server.run(port=5000,host='0.0.0.0')

If I create the same plot in the notebook it works the way I think it should – I can see individual hover text for ever point.

# create fig identically
iplot(fig)

I’m using

dash-core-components (0.15.0rc1)
dash (0.20.0)
plotly (2.4.1)

you’ll need to upgrade dash core components to at least 0.16.0. see the changlog here: https://github.com/plotly/dash-core-components/blob/master/CHANGELOG.md

Add hover labels and selections to box points [https://github.com/plotly/plotly.js/pull/2094]

@chriddyp cool, thanks. Is there a version that also supports dash-table-experiments?

@chriddyp sorry, I got confused. The dash-table-experiments works fine. What I meant was the Tabs components.

I just updated! Upgrade with pip install dash-core-components==0.21.0rc1

1 Like

@chriddyp thank you! works great

1 Like