Skip to content

fix(heatmap): resolve color_scale to the plotly.js built-in names so the default draws viridis - #111

Merged
jvdd merged 1 commit into
mainfrom
fix/color-scale-names
Sep 28, 2026
Merged

jvdd merged 1 commit into
mainfrom
fix/color-scale-names

Conversation

@jvdd

@jvdd jvdd commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Closes #100.

Change

  • color_scale has one vocabulary: the 18 built-in color scales of plotly.js 4.1.1 (checked against src/components/colorscale/scales.js). The list lives in flexviz/trace/_hist_helpers.py.
  • normalize_heatmap_color_scale matches a name without regard to case and returns the Plotly spelling. An unknown name raises ValueError with the list of valid names, when the trace is built.
  • The trace defaults are "Viridis" (Histogram2D, GeoHistogram2D, absolute CorrHeatmap) and "RdBu" (signed CorrHeatmap).
  • The Plotly adapter resolves the name through the same helper, so a spec decoded from an older share URL with "viridis" renders viridis.
  • plasma, magma and inferno are removed from the docs and from the ECharts color arrays. plotly.js has no such scales.
  • Architecture.md and the three color_scale docstrings describe the vocabulary.

Impact

Tests

  • New browser test test_hist2d_default_color_scale_renders_viridis reads _fullData[0].colorscale. It fails on main (rgb(220,220,220), Reds) and passes here.
  • Unit tests for the case-insensitive lookup and the rejected name, and an adapter test for a lowercase decoded name.
  • pytest tests flexviz_polars/tests: 2394 passed, 2 skipped.
  • pytest -m browser tests: 317 passed, 12 skipped.

@codspeed

codspeed Bot commented Sep 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing fix/color-scale-names (4514842) with main (dbc1e0f)

Open in CodSpeed

@jvdd
jvdd merged commit 7a5f1fb into main Sep 28, 2026
18 checks passed
@jvdd
jvdd deleted the fix/color-scale-names branch September 28, 2026 09:11
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.

Plotly heatmaps ignore lowercase color_scale names: the default viridis renders as Reds

1 participant