Having a transparent background in Plotly Express

Can anyone tell me how to make the background transparent in plotly express?

For eg,
In the following snippet what would i change in order to make the background transparent? I want to return this fig to a dash graph component and it looks weird with the white background.

import plotly.express as px
tips = px.data.tips()
fig = px.bar(tips, x=“sex”, y=“total_bill”, color=“smoker”, barmode=“group”)


You can update the layout of the figure like in the code below:

import plotly.express as px
tips = px.data.tips()
fig = px.bar(tips, x=‘sex’, y=‘total_bill’, color=‘smoker’, barmode=‘group’)

‘plot_bgcolor’: ‘rgba(0, 0, 0, 0)’,
‘paper_bgcolor’: ‘rgba(0, 0, 0, 0)’,


In rgba(0,0,0,0) the a letter stands for the alpha channel, so setting it to 0, makes the color transparent.


Thanks! This is exactly what i was looking for

1 Like

It is not making my default background color disappear. I want to make my plot background white. Any other way I can make my plot_bgcolor white/transparent.

Have you managed to find a way to make default background different color? When there is no data, default background is always white. How can I change it?