`labelalias` in `Scatter.marker.colorbar` can't handle negative values
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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:
Expected behavior
The label -10 is replaced by Negative
Context
python==3.11plotly==5.24.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python example from the issue with Scatter.marker.colorbar, tickvals=[-10, 0, 10], and the supplied labelalias mapping. Trace how negative tick aliases are handled and verify that the completed change replaces the -10 tick label with "Negative" while preserving the other labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100