-
-
Notifications
You must be signed in to change notification settings - Fork 1
Consider removing column name and = sign in legend #36
Comments
Thanks for the input! This is the best compromise I could find at the moment for dealing with cases where in fact it's not easy to infer from the value (i.e. the values are "Yes" and "No" and the column is called "Smoker" etc) and because when you are using colours and symbols, you need to be able to differentiate which is which ("smoker=Yes, child=Yes" vs "Yes, Yes"). The best way to deal wit this would be to have separate legends for color, symbol, size and line-dash, with titles, but plotly.js doesn't (yet) support this kind of thing. In terms of how to actually get the effect you want, unfortunately you'll have to iterate through the traces and change the names. We're looking at various ways to make that easier: plotly/plotly.py#1484 |
Hi @nicolaskruchten eventually I found the time to reply!
From my experience, such ambiguity would be limited as the graph would come with a title s.a evolution by smoking behaviour. But I hadn't realized you could have composed categories, in this case, I understand that might be tricky.
|
You could of course use this to edit any property etc. |
If you just want to show the values in legend, you can use this:
like if you have something like:
so the below snippet will remove the "alert_role" and will show only values like cpu, clone,memory etc: The output will be:
|
This is actually no longer necessary... As of Plotly.py 4.5, Plotly Express no longer puts the |
Love the update to the legend in 4.5! Now I'm wondering if there's a way to supress the '=' expression from the titles of sub-plots. or if not, is there a helper function like there used to be for traces, something like: for_each_subplot( lambda z: z.update(title=z.title[(z.title.find("=")+1):])) |
Yep: import plotly.express as px
fig = px.scatter(px.data.tips(), x="total_bill", y="tip", facet_col="smoker")
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
fig.show() |
@jdamiba can you add this example to the facet docs please? ☝️ |
Similarly, is there a way to hide the facet_col appearing as a header above subplots? |
Hey, is there a way to set the x and y axis label for every subplot? |
This is a working solution of course, but it seems odd for this hack to be necessary. |
Uh oh!
There was an error while loading. Please reload this page.
Hi again @nicolaskruchten,
Something that puzzled me about the
color
arg in the plot is that it includes the name of the column followed by an equal sign. Would you consider removing it and just let the value of the column in place? Here are a few reasons to support that point :date=
orcountry=
it easy to infer by the value of the fieldAlso, for personal taste, I think equal sign does not play well outside equations and prefer
:
instead.Happy to discuss with you about it. Maybe there is an option that can disable it, that I am not aware of.
The text was updated successfully, but these errors were encountered: