Skip to content

Incorrect legend style with x unify hovermode #4882

Description

@FabioMosella

Hello

I noticed that something is incorrect with the legend styling, especially when we use the x unify hovermode.

Here is a short example:

import plotly.graph_objects as go

x = ["A", "B"]
fig = go.Figure(data=[
    go.Bar(
        x=x, 
        y=[1, 1],
        marker=dict(color=["blue", "red"], pattern_shape=["/", ""]),
        name="First Bar"
    ),
    go.Bar(
        x=x, 
        y=[-1, -1],
        marker=dict(color=["green", "purple"], pattern_shape=["/", ""]),
        name="Second Bar",
    ),
])

fig.update_layout(hovermode="x unified")
fig.show()

Image

As we can see, the second bar uses the "general" legend style, which leads to an incorrect style for the items on the right.
plotly version = 5.24.1

And thank you for your amazing work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions