color_continuous_scale causes a bug when the last item is not 1.0
未关闭
还没有人认领这个 Issue。
bug
P3
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
import plotly.express as px
import numpy as np
df = px.data.gapminder().query("year == 2007")
fig = px.treemap(df, path=[px.Constant("world"), 'continent', 'country'], values='pop',
color='lifeExp', hover_data=['iso_alpha'],
color_continuous_scale=[(0, 'red'), (0.4, 'yellow'), (1.0, 'green')],
color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
This gives me the result I want.
However, something like:
color_continuous_scale=[(0, 'red'), (0.4, 'yellow'), (0.8, 'green')],
creates a whole separate treemap.
This fixes the issue:
color_continuous_scale=[(0, 'red'), (0.4, 'yellow'), (0.8, 'green')], (1.0, 'green')],
I'm not sure if there's anything to even technically "fix" here, but it was expected behaviour that I didn't get.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 Plotly Express treemap 复现代码,并检查 treemap 如何处理 color_continuous_scale。确认缩放的最终位置低于 1.0 时的行为,然后添加一个回归测试,表明它不会创建单独的 treemap,并保留预期的着色效果。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- numpy, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100