-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
single legend for multiple traces / share legend across subplots / disable automatic mapping of fill, color, etc #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, the behaviour I want can be obtained by overriding mapping manually (I think I am too used to R and it's mapping), and using a combination of legendgroup and showlegend = False. Code below:
|
Thanks for reporting. I also use the manual mapping as you document, as I found no other way, but I feel it's a bit too low level. I've open cf. plotly/plotly.js#2744 to see if we can get a better way. |
The problem here is not all classes might appear in all subplots. If you chose a subplot for the legend that has not all classes then the missing ones will not show up in the legend. |
Hello,
I am not sure whether this is a bug or a feature to request, perhaps it's in between.
the problems: mapping of data to the legend seems automatic and cannot be disabled. If traces share names (I think) they should be plotted with a unique legend name and not with one name per trace, repeating the names.
example:
I have a plot with a legend with two elements: 'name': 'trace1' and 'name':'trace2' but four actual traces, which I divide in two groups by marker symbol. The result is a plot per trace (correct), mapping of legend to both color and symbol (not desired), and repeated trace names in the legend (I would like the trace names to show as unique names).
expected behaviour: No automatic mapping, the user can decide whether to map or not (e.g. ggplot2 from R does this. E.g. with 'color', if it is within an aesthetic group it's mapped, but when it is outside that group it is fixed and does not appear in the legend). Since two traces share a name, they should be mapped to a single name in the legend, and when clicking on that name both traces should get hidden.
suggested workarounds: Hide some legend names. However this is not good, because if the legend is hidden the traces cannot be accessed from it. I expect that a unique legend name controls more than one trace in the plot.
example code:
Thank you very much for all contributions, I wished I knew enough to help myself!
The text was updated successfully, but these errors were encountered: