Skip to content

Commit 3c0a82a

Browse files
committed
viz: fix colorbar label width to 11 chars for negative scientific notation
1 parent ed7e39d commit 3c0a82a

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

toolchain/mfc/viz/tui.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,8 @@ def render(self): # pylint: disable=too-many-branches,too-many-locals,too-many-
241241
h_plot_avail = max(self.size.height - 4, 4) # -2 border, -2 header+footer
242242

243243
# Right side: gap + gradient strip + value labels.
244-
# Compute label width dynamically so long labels (e.g. "-2.26e-05")
245-
# are never truncated. Use the full-data range as a conservative
246-
# estimate — it is always ≥ the zoomed-window range.
247-
if self._vmin is not None and self._vmax is not None:
248-
_vmin_est, _vmax_est = self._vmin, self._vmax
249-
elif self._data is not None:
250-
_finite = self._data[np.isfinite(self._data)]
251-
_vmin_est = float(_finite.min()) if _finite.size else 0.0
252-
_vmax_est = float(_finite.max()) if _finite.size else 1.0
253-
else:
254-
_vmin_est, _vmax_est = 0.0, 1.0
255-
if _vmax_est <= _vmin_est:
256-
_vmax_est = _vmin_est + 1e-10
257-
_mid_est = (_vmin_est + _vmax_est) / 2
258-
_CB_LBL = max(
259-
len(f" {_vmax_est:.3g}"),
260-
len(f" {_vmin_est:.3g}"),
261-
len(f" {_mid_est:.3g}"),
262-
)
263-
_CB_GAP, _CB_W = 1, 2
244+
# 11 chars fits negative scientific notation e.g. " -2.26e-05".
245+
_CB_GAP, _CB_W, _CB_LBL = 1, 2, 11
264246
w_map_avail = max(w_plot - _CB_GAP - _CB_W - _CB_LBL, 4)
265247

266248
# Preserve the physical x/y aspect ratio.

0 commit comments

Comments
 (0)