Repository navigation
Description
Context
In overlay mode, a figure that another figure filters draws two layers: all rows as a faint background (16 % opacity), and the filtered rows on top. For a histogram or a line, the faint layer shows the whole distribution behind the filtered one, so the user can compare the subset with the whole.
PR #103 fixes the overlay for a geo_histogram2d target (#97). Before that fix, the overlay design for the heatmap-like targets was reviewed with a demo on real data. The decision was to keep the overlay as it is for now, and to consider dropping it for these targets later. This issue records the findings.
Demo
- Data: GOES-19 lightning, every 12th day from Sep 2025 to Aug 2026: 30 days, 30,502,345 flashes.
- Filter: a brush on a local solar hour histogram, at 3–5 h (night) and at 15–17 h (the afternoon peak).
- Targets:
histogram2dof lon and lat (200 × 100 bins, log colors),geo_histogram2d(100 × 200 bins, log colors), andcorr_heatmapof lat, lon and local_hour. - Compared: update mode, overlay mode (with the PR fix(adapters): draw a geo_histogram2d overlay target and fade its background #103 fixes), and two mockups: a grey footprint and a share-of-cell view.
Findings
- Overlay adds only one fact to a heatmap: the cells that have rows but none in the selection. The filtered layer uses the whole color channel, so a heatmap cannot show the proportion that ghost bars show behind a histogram.
- That one fact is hard to read. On a dark plot, the 16 % background is almost invisible. On a light map, it turns into a pale mesh, and faded bright cells look nearly white, which reads as data.
- The two layers have separate color ranges, so a background color and a foreground color never mean the same value.
corr_heatmaplooks the same in both modes. Every cell has a value, so the foreground covers the whole background.- A grey footprint, the background in one neutral color, makes finding 1 easy to read.
- A share-of-cell view (filtered rows ÷ all rows per cell) is the real comparison: night lightning sits over the ocean, and the afternoon peak over land. But it is noisy where a cell has few rows, because a handful of rows gives 0 % or 100 %. It needs a minimum count per cell.
After a zoom, the background keeps its old grid
Found while reviewing PR #103. Reproduced in Chromium on that branch, in overlay mode with an active selection:
- A real zoom re-bins the filtered layer, but the faded background keeps its grid from before the zoom.
geo_histogram2d: 5 × 5 background cells of 4.8°, under 6 × 6 filtered cells of about 4.4° × 6.6°. The cell borders do not line up.histogram2d(the same onmain): background bins of width 1.2, filtered bins of width 0.4.
- Cause:
FlexEngine._background_specs(flexviz/engine.py) drops the background of everyfiltered_onlytrace while a selection is active, also for aviewportevent. The client then draws the cached background from before the zoom. - A box selection on a zoomed overlay map then gets the wrong box.
geoSelectionFromPoints(plotly/events.js) looks up each selected cell in the first trace with the logical uid, which is the background. A filtered cell's id then points to another rectangle. Example: a box over lon and lat 5.2–9.4 selects 4.8–9.6 without a zoom, but 4.8–19.2 after one. This is reachable onmainwith a log norm, and after PR fix(adapters): draw a geo_histogram2d overlay target and fade its background #103 also with a linear norm.
The engine's filtered_only rule effectively means "no fresh background while a selection is active". Drawing a stale one contradicts that, which supports the proposal below. If the overlay stays instead, two fixes are needed: recompute the background of these traces on a viewport event, and look up each selected cell in its own trace.
Proposal to evaluate
In overlay mode, draw a histogram2d, geo_histogram2d or corr_heatmap target as update mode does: the filtered layer only.
This also removes the stale background and the wrong selection box above. It would probably remove the two-layer handling for heatmaps, all of it in plotly/traces.js (to verify):
syncHeatmapOverlayColorScaleandfvFinalizeHeatmapOverlayColorbars(also called fromplotly/render.js), which move the colorbar from the background to the filtered layer.- The background/foreground branch in
applyHeatmapColorbarPolicy. heatmapZFiniteExtentandheatmapHasRenderableCells, which only serve the two above.applyMapLayerOpacityfrom PR fix(adapters): draw a geo_histogram2d overlay target and fade its background #103, which fades the map background.
Questions to answer first:
- Deselect: a target needs its unfiltered data again when the selection is cleared. Today that comes from the cached background layer. Check that the cache and the engine's
filtered_onlyrule still cover it. - Live brushing: check the cube path for a
histogram2dorcorr_heatmaptarget (fvCubeTraceFilteredOnly, and the fg layer during a gesture). - Users: the mode toggle then changes nothing for these figures. Say so in the docs, or show it in the toolbar.
- Alternatives: the grey footprint is a small rendering change. The share view is a new feature, better as an explicit option than as the default overlay.
Activity
jvdd commentedon Sep 29, 2026
Decision (2026-09-29): keep overlay mode for the heatmap targets and patch both bugs. 1) On a viewport event with an active selection, send the background of a filtered-only trace again, so the background grid follows the zoom. 2) A geo box select must look up cells in the filtered (foreground) trace, not in the first trace with the logical uid.