Skip to content

offsetgroup with horizontally stacked/relative bar traces #5007

@neutralino

Description

@neutralino

It appears the feature to allow offsetgroup to work with stacked/relative bar traces (plotly/plotly.js#7009) does not work with horizontally oriented bar traces. Taking the example from the documentation

https://plotly.com/python/bar-charts/#grouped-stacked-bar-chart

if I reverse the x and y axis and set orientation to 'h', the traces are not separated by the different offset groups:

import plotly.graph_objects as go

data = [
    go.Bar(
        y=['Q1', 'Q2', 'Q3', 'Q4'],
        x=[150, 200, 250, 300],
        name='New York',
        offsetgroup="USA",
        orientation='h'
    ),
    go.Bar(
        y=['Q1', 'Q2', 'Q3', 'Q4'],
        x=[180, 220, 270, 320],
        name='Boston',
        offsetgroup="USA",
        orientation='h'
    ),
    go.Bar(
        y=['Q1', 'Q2', 'Q3', 'Q4'],
        x=[130, 170, 210, 260],
        name='Montreal',
        offsetgroup="Canada",
        orientation='h'
    ),
    go.Bar(
        y=['Q1', 'Q2', 'Q3', 'Q4'],
        x=[160, 210, 260, 310],
        name='Toronto',
        offsetgroup="Canada",
        orientation='h'
    )
]

layout = go.Layout(
    title={
        'text': 'Quarterly Sales by City, Grouped by Country'
    },
    yaxis={
        'title': {
            'text': 'Quarter'
        }
    },
    xaxis={
        'title': {
            'text': 'Sales'
        }
    },
    barmode='stack'
)

fig = go.Figure(data=data, layout=layout)

fig.show()

Image

Using plotly 6.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions