# Having a transparent background in Plotly Express

**URL:** <https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205>\
**Category:** plotly.js\
**Created:** [October 18, 2019, 7:51am UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205 "2019-10-18T07:51:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Indranet](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@Indranet](https://community.plotly.com/u/Indranet)\
**Post date:** [October 18, 2019, 7:51am UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205/1 "2019-10-18T07:51:38Z")

</div>

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”)  
fig.show()

Thanks

---

<div class="post-metadata">

**Author:** ![MarevaZenelaj](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@MarevaZenelaj](https://community.plotly.com/u/MarevaZenelaj)\
**Post date:** [October 18, 2019, 12:55pm UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205/2 "2019-10-18T12:55:39Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/0/0850a279af9ca6d81f087b187fa7b67e7577ea97.png)

Code:  
import plotly.express as px  
tips = px.data.tips()  
fig = px.bar(tips, x=‘sex’, y=‘total\_bill’, color=‘smoker’, barmode=‘group’)

fig.update\_layout({  
‘plot\_bgcolor’: ‘rgba(0, 0, 0, 0)’,  
‘paper\_bgcolor’: ‘rgba(0, 0, 0, 0)’,  
})

fig.show()

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

---

<div class="post-metadata">

**Author:** ![Indranet](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@Indranet](https://community.plotly.com/u/Indranet)\
**Post date:** [October 22, 2019, 8:05am UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205/3 "2019-10-22T08:05:03Z")

</div>

Thanks! This is exactly what i was looking for

---

<div class="post-metadata">

**Author:** ![bgroy](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@bgroy](https://community.plotly.com/u/bgroy)\
**Post date:** [September 23, 2020, 2:46am UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205/4 "2020-09-23T02:46:49Z")

</div>

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.

 ![Screenshot_2020-09-23 3D descriptors - Jupyter Notebook](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/b/b7f730f8017f6dd290a5f7a8e94dda898731c99b.png)

---

<div class="post-metadata">

**Author:** ![esnjdra](https://avatars.discourse-cdn.com/v4/letter/e/ed8c4c/32.png) [@esnjdra](https://community.plotly.com/u/esnjdra)\
**Post date:** [June 16, 2021, 3:00pm UTC](https://community.plotly.com/t/having-a-transparent-background-in-plotly-express/30205/5 "2021-06-16T15:00:26Z")

</div>

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?
