Skip to content

Place a one-value heatmap at its category on a category axis - #8176

Open
X6M-Work wants to merge 2 commits into
plotly:mainfrom
X6M-Work:fix-heatmap-single-category-x-8175
Open

X6M-Work wants to merge 2 commits into
plotly:mainfrom
X6M-Work:fix-heatmap-single-category-x-8175

Conversation

@X6M-Work

Copy link
Copy Markdown
Contributor

Fixes #8175.

A heatmap trace with one x value on a category axis now sits at its category.

Cause

On a category axis, clean_2d_array.js lays out z on all the axis categories. So the bricks of every trace must start at 0, as they do for a trace with two or more x values. For a trace with one value, make_bound_array.js started the bricks at that value, the category index. The column then moved a second time, from index 2 to position 4 in the issue example. The same shortcut applies to y, and the same fix covers it.

Change

make_bound_array.js skips the one-value shortcut on a category axis. Other axis types keep the shortcut.

Tests

The new case in heatmap_test.js plots the two traces from the issue. It expects the bricks of the second trace at [-0.5, 0.5, 1.5, 2.5] and the x axis range at [-0.5, 2.5]. On main, the case fails with Expected 1.5,2.5,3.5,4.5 to be close to -0.5,0.5,1.5,2.5 and Expected -0.5,4.5 to be close to -0.5,2.5.

Local runs on Windows 11 with Chrome 157:

  • heatmap_test.js: 51 of 51 pass
  • contour_test.js and histogram2d_test.js: 48 of 48 pass
  • npm run lint and npm run typecheck pass

npm run test-syntax fails on the window.getComputedStyle count on this machine, with and without the change. I did not run the image baseline tests.

clean_2d_array lays z out on all the axis categories, so the bricks must
start at 0. The one-value shortcut started them at the category index,
which moved the column a second time.

Fixes plotly#8175
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]: Heatmap with a single x value on a category axis is drawn at 2× its category index

1 participant