Summary
I’m looking for a way to get Streamlit’s default color palette as a list of hex codes. My goal is to be able to color the background of rows in a table to match other plots in my app.
Details
The code below works using default plotly colors and by setting the theme of all my plots to theme=None
to disable the default Streamlit theme. However, I’d like to recreate this using the default Streamlit color palette so that everything is more cohesive. Is there something I can replace plotly.colors.DEFAULT_PLOTLY_COLORS
with below that would achieve the desired results?
Code snippet:
def get_color_map(camps):
res = {}
for i in range(len(camps)):
res.update({camps[i]: plotly.colors.DEFAULT_PLOTLY_COLORS[i]})
return res
def color_camps(val):
color = cmap[val]
return f'background-color: {color}'
cmap = get_color_map(st.session_state['campaigns'])
top_la = top_df.sort_values(by=['LA'], ascending=False).reset_index()
st.table(top_la[['Campaign', 'LA']].head(10).style.applymap(color_camps, subset=['Campaign']))
Debug info
- Streamlit version: 1.16.0
- Python version: 3.7.3
Requirements file
streamlit==1.16.0
google-auth==2.14.0
google-cloud-bigquery==3.3.5
db-dtypes==1.0.4
json5==0.8.4
jsonschema==3.0.1
pandas==1.3.5
plotly==5.11.0
plotly-express==0.4.0
jj-data-connector @ git+https://github.com/DataSolveProblems/jj_data_connector.git@ea9ccde1fee7ad382f5e145f5a0bfc7e26a2341c
gsheetsdb==0.1.13.1
millify==0.1.1
plotly-calplot==0.1.7
Links
- Link to your GitHub repo: GitHub - izzybry/streamlit-app-repo
- Link to your deployed app: https://cl-ftm-dash.streamlit.app/