Black and white colors are only seen when Plotly is downloaded as html file or a png or jpeg file


Black and white colors are only seen when Plotly is downloaded as html file or a png or jpeg file, not sure the reason behind the same, but same code is working when locally running a python file.

Steps to reproduce

Code snippet:

def PIE_CHART(Categorical_Data, column):

    Categorical_Data : TYPE
    column : TYPE


    category_list = list(Categorical_Data[column].unique())
    len_Dict = {}
    for category in category_list:
        len_Dict[category] = len(Categorical_Data[Categorical_Data[column] == category])
    LEN = pd.DataFrame(len_Dict, index =["values"])
    LEN = LEN.T.reset_index().rename(columns = {"index":"names"})
    PIE = px.pie(LEN, values='values', names='names', hole=.3)
    # save html file
    PIE.write_html('Volume Visualization/pie/example_graph.html')
    st.plotly_chart(PIE,theme = None, use_container_width= True)

Expected behavior:

Plotly html file should appear with colors .

Actual behavior:

html file is getting downloaded without any colors only black color can be seen…

Please assist on this if there is any better approach or i am missing out on any thing please highlight.

This is strange indeed.

Without streamlit

write_html() works fine

With streamlit

write_html() works fine
    streamlit <= 1.15.1

write_html() has issues
    streamlit >= 1.15.2

All tests with plotly==5.13.0

plotly_chart works fine in all streamlit versions. Color is not black and white.

Sample code

import streamlit as st
import as px

df =
fig = px.pie(df, values='tip', names='day')


st.plotly_chart(fig, theme='streamlit', use_container_width=True)

Hi everyone,

This is actually expected because we change the underlying colors to black and then replace them on the front end to colors that match our dark or light theme best.

In order to deal with this, you can use this something like this:

import as pio
import streamlit as st
import as px

pio.templates.default = "plotly"

df =
fig = px.scatter(
    title="streamlit colors",

@willhuang it worked thank you.

hey @willhuang, I like to know one more thing, is there a way to download streamlit page as html.

Hi @Dkdatascientist ,

I think there will be a print option that will allow you to download as a pdf. I’m not sure if you can download it as html. Why would u need the html?

I am creating a interactive dashboard, incase if it is downloaded as html the interactivity will be there so it can be used for any presentation.

I don’t think we offer that functionality as of right now. However, you can create an enhancement here:

1 Like

Hi @Dkdatascientist , I just got tagged and it looks like there is a hack to be able to download the plotly chart as html: Download Plotly plot as html

1 Like

hey @willhuang thanks for the reply, I saw that already in fact I am using same kind of method to download it as html. But I can only download the graph not the streamlit widgets.

Ah I see. I don’t think we have a way to do that right now! :frowning: