Skip to content
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

Cannot reverse grouped legend of stack bar chart #1658

Closed
manycoding opened this issue Jul 6, 2019 · 1 comment
Closed

Cannot reverse grouped legend of stack bar chart #1658

manycoding opened this issue Jul 6, 2019 · 1 comment

Comments

@manycoding
Copy link

I want the legend groups of stacked bar charts to follow the data, i.e. if the data is displayed top to bottom, the groups should be the same.

layout.legend.traceorder doesn't help, "grouped+reversed" reverses the labels in group.

import plotly.graph_objs as go
from plotly.colors import DEFAULT_PLOTLY_COLORS

data = []
for vc in [pd.Series([10, 50, 40], index=["a","b","c"], name="group_a"),
           pd.Series([80, 20], index=["i",None], name="group_b")]:
    data = data + [
        go.Bar(
            x=[counts],
            y=[vc.name],
            name=str(value)[:30],
            orientation="h",
            legendgroup=vc.name,
            marker_color=DEFAULT_PLOTLY_COLORS[i % 10],
        )
        for i, (value, counts) in enumerate(vc.items())
    ]
layout = go.Layout(
    barmode="stack",
)
go.FigureWidget(data, layout)
@gvwilson
Copy link
Contributor

Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants