[BUG]: `histogram2dcontour` uses wrong fill colors for negative values
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die bereitgestellte CodePen-Reproduktion für einen histogram2dcontour-Trace mit negativen z-Werten und auf avg, min oder max gesetztem histfunc auszuführen. Verfolge den histogram2dcontour-Rendering-Pfad und überprüfe, dass die Konturfüllungen für negative Bins bei allen drei Funktionen mit ihren Beschriftungen und der colorscale übereinstimmen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 65/100