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):
"""
Parameters
----------
Categorical_Data : TYPE
DESCRIPTION.
column : TYPE
DESCRIPTION.
Returns
-------
None.
"""
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)
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 plotly.io as pio
import streamlit as st
import plotly.express as px
pio.templates.default = "plotly"
df = px.data.tips()
fig = px.scatter(
df,
x="total_bill",
y="tip",
color="day",
color_discrete_sequence=[
"#0068c9",
"#83c9ff",
"#ff2b2b",
"#ffabab",
"#29b09d",
"#7defa1",
"#ff8700",
"#ffd16a",
"#6d3fc0",
"#d5dae5",
],
title="streamlit colors",
)
st.plotly_chart(fig)
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?
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.