Search code examples
pythonplotly

How can I export a plotly table without a background (not transparent)?


I was trying to make a table with plotly lib, and upon exporting, I realized that it exports the table with a background, so I decided to make the background transparent, but it turns out I need to export the table without a background. This is what I've tried:

layout = dict(
    paper_bgcolor='rgba(0,0,0,0)',
    plot_bgcolor='rgba(0,0,0,0)'
)

fig = go.Figure(layout=layout, data=[go.Table(
    header=dict(values=['A Scores', 'B Scores'],
                line_color='darkslategray',
                fill_color='lightskyblue',
                align='center'),
    cells=dict(values=[[100, 90, 80, 90], # 1st column
                       [95, 85, 75, 95]], # 2nd column
               line_color='darkslategray',
               fill_color='lightcyan',
               align='center'))
])

fig.update_layout(width=350, height=350)
fig.show()

The result:

Table with transparent background

What I'm expecting is:

Table without a background


Solution

  • From your screen shots, you are really meaning margins. These can be set to zero

    fig.update_layout(width=350, height=350, margin={"l":0,"r":0,"t":0,"b":0})