[BUG]: `histogram2dcontour` uses wrong fill colors for negative values

Aperta
#8,005 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Inizia eseguendo la riproduzione CodePen fornita per una trace histogram2dcontour con valori z negativi e histfunc impostato su avg, min o max. Segui il percorso di rendering di histogram2dcontour e verifica che i riempimenti dei contorni dei bin negativi corrispondano alle relative etichette e alla colorscale per tutte e tre le funzioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug P2 size: 1

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:
Image

Expected behavior

Contour fills should match fill colors indicated by colorscale

Lingua principale
JavaScript
Stelle
18.3k
Fork
2k
Merge medio
2g 10h
PR unite (30g)
30

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di plotly/plotly.js

Tutte le issue di plotly/plotly.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.