You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
histogram2d hover over an empty bin: choose one label for both color norms (z: NaN today) #102
The server sends an empty histogram2d bin as null, so the renderer draws a gap and not a zero-count cell. The Plotly hover over that gap shows z: NaN, with both color norms.
What an empty bin really holds depends on the aggregation:
A count (no z), histfunc="sum" and histfunc="n_unique": the value is 0.
histfunc="mean", "median", "min" and "max": there is no value, because the bin has no rows. NaN does not tell the user that.
A histnorm applies to the count, so its empty bin is also 0.
The hover over a gap must stay, because it drives linked hover (plotly_hover). hoverongaps: false removes the linked guide over empty cells.
Reachability
Hover over an empty bin of any add_histogram2d. Reproduced in Chromium: a figure with 4 x-bins, one of them empty, shows x: 1.875 y: 0.5 z: NaN.
Constraint: how Plotly labels an empty cell
Plotly.js 3.0.0, hover over the empty bin of a heatmap:
Value of the empty cell
Template
Label
null
%{text:.10~r}
z: 0
null
%{text}
z: null
NaN
%{text:.10~r}
z: NaN
The linear norm uses the default hover, which prints NaN for a null z. No template fallback fires on null. So any label other than 0 or null needs a copy of the values with the label in its place.
With color_norm="log", the hover reads the raw values from text (applyLogColorNorm in flexviz/adapters/js/plotly/traces.js). To keep the NaN label of the linear norm, PR #95 copies the grid and turns null into NaN.
Cost in Chromium, 1320 × 1150 bins: about 10–20 ms per layer, or 7–15 % of a render (full render 129–148 ms with the copy, 121–123 ms without). In overlay mode, the copy runs for both layers.
Decision
Choose one label rule for both norms:
Count, sum and n_unique: z: 0. This needs no copy. The log norm can put the raw values in text as they are, because %{text:.10~r} prints null as 0. The linear norm can use a template with %{z:.10~r}.
mean, median, min and max: a label such as z: no rows. This needs a copy with the label in place, in both norms. The alternative is to keep NaN for these.
Then remove the NaN copy from applyLogColorNorm for the traces that need no copy.
Regression tests
Browser tests, for both norms:
Hover an empty bin of a count histogram2d and check the label.
Hover an empty bin of a histfunc="mean"histogram2d and check the label.
Check that the linked guide still appears on a histogram of the same column.
changed the title [-]histogram2d hover shows z: NaN over an empty bin[/-][+]histogram2d hover over an empty bin: choose one label for both color norms (z: NaN today)[/+]on Sep 27, 2026
Activity
[-]histogram2d hover shows z: NaN over an empty bin[/-][+]histogram2d hover over an empty bin: choose one label for both color norms (z: NaN today)[/+]