Skip to content

Bar(orientation='h') together with Layout(barmode='overlay') not overlayed #3458

Closed
@Nic30

Description

@Nic30

Hello,

from plotly.graph_objs import Figure
from plotly import graph_objs as go

fig = Figure([go.Bar(x=[1, 2, 3], y=[3, 1, 2]),
                    go.Bar(x=[1, 2, 3], y=[0.3, 0.4, 0.1], width=[0.4, 0.6, 0.2])],
                    go.Layout(barmode='overlay',))
fig.show()

Works as expected.
image

However if orientation='h' is set the bars do not overlay.
EDIT: I forget to swap the x/y values, it works fine, I maybe did similar mistake when using plotly.express.timeline.

fig = Figure([go.Bar(x=[3, 1, 2], y=[1, 2, 3], orientation='h'),
                    go.Bar(x=[0.3, 0.4, 0.1], y=[1, 2, 3], width=[0.4, 0.6, 0.2], orientation='h')],
                    go.Layout(barmode='overlay',))
fig.show()

image

$ python3 --version
Python 3.8.10
$ pip freeze | grep plotly
plotly==4.9.0

This is a serious complication for me because I was using plotly.express.timeline and if I specify colors (which internally generates multiple go.Bar instances) I can not have tasks on same row which is essential for my application (circuit scheduling visualization).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions