Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display hover info on a plotly Table?

Tags:

python

plotly

I would like to display hover info over a plotly Table. This is my best guess, but no hover text shows up in a jupyter notebook or when the figure is exported to html and viewed in a browser:

import plotly.graph_objects as go

hover_text = [['hover a', 'hover b', 'hover c'],
              ['hover d', 'hover e', 'hover f']]

fig = go.Figure(data=[go.Table(
    cells={'values': [['a', 'b', 'c'],
                      ['d', 'e', 'f']]},
    hoverinfo='text',
    meta={'text': hover_text}
)])

fig.show()
fig.write_html('test.html')

plotly version 4.5.4

There are a number of go.Table() parameters that seem like they may be relevant, but I have not found a combination that displays anything:

  • hoverinfo
  • hoverinfosrc
  • hoverlabel
  • meta
  • metasrc
  • customdata
  • customdatasrc

Some references I've been looking at:

  • https://plotly.github.io/plotly.py-docs/generated/plotly.graph_objects.Table.html
  • https://plotly.com/python/table/
  • https://plotly.com/python/hover-text-and-formatting/#hover-labels
  • https://plotly.com/python/reference/#table
like image 669
cnash Avatar asked Jun 23 '20 16:06

cnash


People also ask

What is Add_trace in Plotly?

Adding Traces To Subplots If a figure was created using plotly. subplots. make_subplots() , then supplying the row and col arguments to add_trace() can be used to add a trace to a particular subplot.


1 Answers

It seems like its a documentation bug and hovers are currently not working with tables. You can check out the open git issue regarding this error: https://github.com/plotly/plotly.js/issues/5523

like image 129
Marian Rick Avatar answered Oct 29 '22 05:10

Marian Rick