Tashus
Tashus

Reputation: 217

Plotly: How to create a table with no header?

I would like to create a table in Plotly (Python) with no header. The table only has two columns, which are essentially "parameter name" and "parameter value", so displaying the explicit column names seems clunky. I am able to create a table with blank column names in the header, but what I really want is a table with only the values.

I have searched the documentation, but was not able to find a way to do this. I tried creating the table without a header object and with header=None, but both of these produce a table with an empty header.

Is it possible to create a table in Plotly without a header, and if so, how?

Upvotes: 3

Views: 4188

Answers (1)

vestland
vestland

Reputation: 61074

The headers will still exist, but you can make them very invisible like this:

fig.for_each_trace(lambda t: t.update(header_fill_color = 'rgba(0,0,0,0)'))

Or:

fig.layout['template']['data']['table'][0]['header']['fill']['color']='rgba(0,0,0,0)'

Here's a complete example that builds on the first example in plot.ly/python/table

Plot:

enter image description here

Code:

import plotly.graph_objects as go

fig = go.Figure(data=[go.Table(
                 cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))])

fig.for_each_trace(lambda t: t.update(header_fill_color = 'rgba(0,0,0,0)'))
fig.layout['template']['data']['table'][0]['header']['fill']['color']='rgba(0,0,0,0)'
fig.show()

This assumes that you're building a plot without any lines between the cells. But you could always make them disappear the same way. I hope this is what you were looking for. If not, then don't hesitate to let me know.

Upvotes: 4

Related Questions