Plotly Express labels dict not applying to traces generated with the color keyword
See original GitHub issueI have a dataframe that I am using to generate an area chart with three components. These components are split out using the color
keyword. Unfortunately, the labels
keyword only renames the title of columns, not the names of traces generated by the color
keyword. In the example below, it would be great to be able to replace steady
, new_users
and churn
with more descriptive labels.
Of course, I can work around this by modifying the original data frame, but the labels
dict is so elegant…
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Creating and updating figures in Python - Plotly
Over 28 examples of Creating and Updating Figures including changing color, size, log axes, and more in Python.
Read more >plotly.express package — 5.11.0 documentation
The keys of this dict should correspond to column names, and the values should correspond to the desired label to be displayed. color_discrete_sequence...
Read more >How to add traces in plotly.express - Stack Overflow
You can add traces using an Express plot by using .select_traces() . Something like: fig.add_traces( list(px.line(...).select_traces()) ).
Read more >Construct various types of Bar Race Charts with Plotly
You should specify the color of the subcategory because if you have different color then the audience will not be able to interpret...
Read more >st.plotly_chart - Streamlit Docs
st.plotly_chart displays an interactive Plotly chart. ... dict/list of plotly.graph_objs. ... import plotly.express as px import streamlit as st df ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right, the
labels
only operate on column names today, although I can see why for figures like this one, legend item text like “steady” could be thought of as a “label”. I might be open to a new keyword argument for this to remap values…in the meantime, you can swap these out post-
px
like this:While these strings come from column data, when shown in the legend, they should count as labels and be subject to
px.defaults.labels
imo.