Skip to content

labelalias in Scatter.marker.colorbar can't handle negative values #4924

Open
@stoney95

Description

@stoney95

I am building a line-chart, which uses a colorgradient. The values of the line chart can be negative and positive. I want to add a colorbar to explain the meaning of the colors in the gradient. For this I use labelalias. The labels only appear for ticks >= 0.

Example

trace = go.Scatter(
  x = x,
  y = y,
  marker = dict(
    color=y,
    colorscale=[(0.0, "royalblue"), (0.5, "rgba(230, 230,230,0.5)"), (1.0, "orange") ]
    colorbar=dict(
                title="Score",
                tickmode="array",
                tickvals=[-10, 0, 10],
                labelalias={-10: "Negative", "0": "Neutral", 10: "Positive"},
                ticks="",
    )
  )
)

The output looks like this:
Image

Expected behavior

The label -10 is replaced by Negative

Context

  • python==3.11
  • plotly==5.24.1

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