plotly / plotly/plotly.js

unexpected histogram bin size behavior

Abierto
#6,556 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug P3
Lenguaje dominante
JavaScript
Estrellas
18.3k
Forks
2k
Merge medio
2 d 12 h
PR fusionados (30 d)
28

Descripción

If the maximum number in the interval is a multiple of the bin size, then this number is lost.
Here is a code example:

var x = [1.0, 9.1, 10.0, 17.8, 18.5, 20.0];

var trace = {
    x: x,
    type: 'histogram',
    autobinx: false,
    xbins: { 
      end: 20.0, 
      size: 10.0,
      start: 0
    }
};
var data = [trace];
Plotly.newPlot('myDiv', data);

Screenshot from 2023-04-07 17-22-43

This is the result of using the notation [a; b) when creating groups. This behavior creates a problem, for example, when you want to dynamically adjust the bin size depending on the step. Here is an example:

var data = [1.0, 9.1, 10.0, 17.8, 18.5, 20.0];

step = 1.0; // any value from the interval: [0; 1]

xbins_start = data.reduce((x, y) => Math.min(x, y), 0.0);
xbins_end   = data.reduce((x, y) => Math.max(x, y), 0.0);
xbins_size  = (step * (xbins_end - xbins_start));

var trace = {
    x: data,
    type: 'histogram',
    autobinx: false,
    xbins: { 
      start: xbins_start,
      end: xbins_end,
      size: xbins_size
    }
};

Plotly.newPlot('myDiv', [trace]);

By setting the step size to 1, I hope to get the only one group containing all the data values (the height of the bin should be 6), instead I get a height of 5 with the loss of the maximum value.

Screenshot from 2023-04-07 17-04-13

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza con la reproducción en JavaScript del issue y sigue la ruta de binning del histograma para los valores explícitos start, end y size de xbins. Verifica el comportamiento en los límites con los datos proporcionados y confirma que un valor igual a end se cuenta en el bin resultante.

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
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.