[BUG]: `histogram2dcontour` uses wrong fill colors for negative values
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.3k
- Forks
- 2k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 28
Descripción
First reported in plotly.py: https://github.com/plotly/plotly.py/issues/3799
histogram2dcontour traces use incorrect fill colors when bin values are negative.
Negative bin values can occur when histfunc is set to 'avg', 'min', or 'max', and the input z array contains negative values.
When some bin values are negative, all negative bin values are filled with the same color as 0 on the colorscale, while the outermost fill level is filled with the same color as the lowest number on the colorscale.
Example
Codepen reproduction: https://codepen.io/emilykl-code/pen/PwpPjMb
Code:
Show code
const x = [1, 2, 3, 4, 1, 2, 3, 4];
const y = [1, 1, 1, 1, 2, 2, 2, 2];
// The bug is triggered when histfunc is 'avg', 'min', or 'max',
// and some z-values are negative such that some resulting bin values
// end up negative
// This example uses all-negative z values to show the most extreme
// case, but not all z-values need to be negative to trigger the bug
const z = [-10, -50, -100, -150, -10, -50, -100, -150];
Plotly.newPlot('div1', [{
type: 'histogram2dcontour',
x: x,
y: y,
z: z,
histfunc: 'avg', // or 'min' or 'max'
contours: {
coloring: 'fill',
showlabels: true,
},
}],
{
title: {
text: 'histogram2d contour plot: wrong fill colors!',
subtitle: {
text: 'Compare contour labels on plot to colorscale'
}
}
});
Screenshot:
Expected behavior
Contour fills should match fill colors indicated by colorscale
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando la reproducción proporcionada en CodePen para un trace histogram2dcontour con valores z negativos y con histfunc establecido en avg, min o max. Sigue la ruta de renderizado de histogram2dcontour y verifica que los rellenos de contorno de los bins negativos coincidan con sus etiquetas y con la colorscale en las tres funciones.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 65/100