`labelalias` in `Scatter.marker.colorbar` can't handle negative values
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 Scatter.marker.colorbar、tickvals=[-10, 0, 10] 以及提供的 labelalias 映射重现 issue 中的 Python 示例。跟踪负 tick 别名的处理方式,并验证完成的更改会将 -10 tick 的标签替换为 "Negative",同时保留其他标签。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100