Different sets of colors with to_step() versus StepColormap() when using a list of custom bins
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- jupyter-notebook, python
调研方向
从链接的 Mapping/colormap_tests.ipynb notebook 开始,比较 linear.RdYlBu_10.to_step(index=bins) 和 StepColormap(colors=color_range, index=bins) 生成的调色板。跟踪 to_step() 和 StepColormap() 如何处理自定义 bins,然后验证二者针对所提供的 bins 生成相同的颜色,同时保留各自的范围。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
I'm finding that, when using a set of custom bins within a colormap, the color palette generated with to_step() differs from that created via StepColormap(), even though both of these methods produce the same palette when custom bins are not requested.
Code that demonstrates this discrepancy can be found within this notebook.
Expected behavior
I would expect that the color palettes generated via the following code would be the same: (I recognize that the range represented by each color will change due to the use of custom bins, but I was expecting the actual colors to remain unmodified).
Method 1:
linear_to_step = linear.RdYlBu_10.to_step(n = 10)
Output:
Method 2:
bins = [-26.57727350868145,
-2.8124548451811697,
-1.3842847014410304,
-0.57942086570913,
0.10509734758955473,
0.803350933220706,
1.5648502030833924,
2.497913057064161,
3.8660584451404807,
5.966706571952004,
25.59683979436641]
custom_bins_to_step = linear.RdYlBu_10.to_step(index = bins)
Output:
Note that, when the second method is used, the interior colors within the color palette get much lighter, though the first and last colors are the same. (See the notebook I linked to earlier for a list of the colors.)
Meanwhile, the following methods that use StepColormap produce the same palettes:
Method 1:
color_range = color_brewer('RdYlBu', n = 10)
linear_stepcolormap = StepColormap(colors = color_range)
Output:
Method 2 (using previously defined color_range and bins values):
custom_bins_stepcolormap = StepColormap(
colors = color_range,
vmin = bins[0], vmax = bins[-1],
index = bins)
Output:
I'm not sure whether this is a bug or if I'm misunderstanding how the to_step() method works, but either way, your help in getting to_step() to produce the same color palette with custom bins that it does without custom bins would be greatly appreciated. I would also be happy to test out any potential fixes/solutions.
Environment:
- Browser [e.g. chrome, firefox]: Running this code via JupyterLab Desktop and Visual Studio Code. Currently writing this on Chrome
- Jupyter Notebook or html files? Jupyter Notebook
- Python version: 3.12.3
- folium version: 0.16.0
- branca version: 0.7.2
Additional context
When custom_bins_to_step and custom_bins_stepcolormap are fed into the same custom choropleth mapping function, they produce very different results:
Map created with custom_bins_stepcolormap:
The colors in the above map match those I'm seeing from a folium.Choropleth() call.
Map created with custom_bins_to_step):
- 主要语言
- Python
- 星标
- 134
- 派生
- 69
- 平均合并
- 1 小时 10 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-visualization/branca 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 58/100
python-visualization/branca#222 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
python-visualization/branca#213 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 42/100
python-visualization/branca#195 ·
-
bug
难度 2/5 1-3 小时 新手友好度 45/100
python-visualization/branca#190 · 6 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
python-visualization/branca#182 ·
查看 python-visualization/branca 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
canonical/paas-charm#368 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
tech debt
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
qualcomm/qai-appbuilder#275 ·