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.
I was struggling to find the solution until my colleague showed me where the solution is.
It was mentioned here, but not specified that it is actually the solution. It is only one line:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking βAccept allβ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.