Skip to content

fix: Correct histogram2dcontour fill colors for negative bin values - #8088

Open
jamalkamaladdin wants to merge 2 commits into
plotly:mainfrom
jamalkamaladdin:fix/8005-histogram2dcontour-negative-fill
Open

jamalkamaladdin wants to merge 2 commits into
plotly:mainfrom
jamalkamaladdin:fix/8005-histogram2dcontour-negative-fill

Conversation

@jamalkamaladdin

Copy link
Copy Markdown

Translations:

No locale files changed.

Features, Bug fixes, and others:

Fixes #8005.

src/traces/contour/close_boundaries.js: an unset contours.type goes to the levels case.
histogram2dcontour has no coerced contours.type.
On main, histogram2dcontour fill levels get no prefixBoundary.
test/jasmine/tests/contour_test.js: new histogram2dcontour case with histfunc: 'avg' and negative z values.
draftlogs: new fix entry.
Jasmine suites: contour, histogram2d, colorscale, contourcarpet.
Moved image baselines: none.
AI disclosure: AI coding agent wrote code, test and text. Author reviewed code before this PR.

histogram2dcontour does not coerce `contours.type`, so closeBoundaries
matched neither switch case and left `prefixBoundary` unset. The empty
bin ring around a histogram2dcontour reads as 0 at the edge, so every
level below 0 needs the perimeter prefix. Without it, those fills
covered only the region below the level, and the region between the
level and the edge took the background color.

Treat an unset `contours.type` as `levels`, the attribute default.

Fixes plotly#8005
@camdecoster

Copy link
Copy Markdown
Contributor

Thanks for the PR! Before I review this PR, could you walk through your potential solution in the issue?

@jamalkamaladdin

Copy link
Copy Markdown
Author

histogram2dcontour never coerces contours.type, so the closeBoundaries switch matches neither case and prefixBoundary stays unset.
Empty edge bins read as 0, so only levels below 0 need that prefix.
#8088 switches on contours.type || 'levels'; levels is the attribute default.
New test in contour_test.js uses this issue's repro and checks prefixBoundary on every fill level.

@camdecoster

Copy link
Copy Markdown
Contributor

Comment in #8005 please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants