Different sets of colors with to_step() versus StepColormap() when using a list of custom bins
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- jupyter-notebook, python
- Domínio
- data-visualization
Direção de pesquisa
Comece pelo notebook vinculado Mapping/colormap_tests.ipynb e compare as paletas de linear.RdYlBu_10.to_step(index=bins) e StepColormap(colors=color_range, index=bins). Analise como to_step() e StepColormap() lidam com bins personalizados e, em seguida, verifique se ambos produzem as mesmas cores para os bins fornecidos, preservando seus intervalos.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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):
- Linguagem predominante
- Python
- Estrelas
- 134
- Forks
- 69
- Merge médio
- 23min
- PRs com merge (30d)
- 2
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-visualization/branca
-
Should LinearColormap.to_step(n=1) create a one-step colormap?Talvez já em andamento @Htet-Kaung-San assumiu há 77 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 58/100
python-visualization/branca#222 · 1 comentário ·
-
Accessibility issue - possible to enable adding HTML attributes to rendered iframe elements?Talvez já em andamento @Htet-Kaung-San assumiu há 49 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
python-visualization/branca#213 · 1 comentário ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
python-visualization/branca#195 ·
-
Colors given as tuple of ints are not working anymore for LinearColormap and StepColormap since v0.8.0Talvez já em andamento @Conengmo assumiu há 575 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
python-visualization/branca#190 · 6 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
python-visualization/branca#182 ·
Todas as issues de python-visualization/branca
Issues semelhantes
-
Claiming namespace `jft63`Abertanamespace operations
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
EclipseFdn/open-vsx.org#14043 ·
Mantenedores costumam responder em até 1 dia
-
feedback simulation workshop
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
githubnext/gh-aw-workshop#4455 ·
Mantenedores costumam responder em até 1 dia
-
Triage 🩺
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitAbertaneeds-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
krkn-chaos/krkn#1627 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NousResearch/hermes-agent#136483 ·
Mantenedores costumam responder em até 1 dia