unexpected histogram bin size behavior
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 18.3k
- Fork
- 2k
- Merge medio
- 2g 12h
- PR unite (30g)
- 28
Descrizione
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);

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.

Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione JavaScript nell’issue e segui il percorso di binning dell’istogramma per i valori espliciti start, end e size di xbins. Verifica il comportamento ai limiti con i dati forniti e conferma che un valore uguale a end venga conteggiato nel bin risultante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100