[BUG]: `histogram2dcontour` uses wrong fill colors for negative values
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript
- Domain
- data-visualization
Research direction
Start by running the provided CodePen reproduction for a histogram2dcontour trace using negative z values and histfunc set to avg, min, or max. Trace the histogram2dcontour rendering path and verify that negative-bin contour fills match their labels and the colorscale across all three functions.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 21
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from plotly/plotly.js
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
chore P3 plotly-internal size: 3 task
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
chore P1 plotly-internal size: 1 task
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
chore P3 plotly-internal size: 1 task
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
plotly/plotly.js#7648 · 3 comments ·
Maintainers usually reply within 1 day
All issues in plotly/plotly.js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
parse-community/parse-server#10699 · 1 comment ·
Maintainers usually reply within 1 day
-
area: dashboard bug perceived difficulty: 3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Nitjsefnie-Harness-Commons/daedalus#1179 ·
Maintainers usually reply within 1 day
-
Aframe enhancement javascript
Difficulty 1/5 Under an hour Newbie friendliness 92/100
webarkit/Aframe-nft#17 ·
-
spec-feedback
Difficulty 2/5 1-3 hours Newbie friendliness 75/100