diff --git a/experiments/plot_model_slices.py b/experiments/plot_model_slices.py index 31b3fe2..237098b 100644 --- a/experiments/plot_model_slices.py +++ b/experiments/plot_model_slices.py @@ -153,9 +153,11 @@ def render(data: Slice, *, reference_outline: bool = False, title: str | None = # under triangle refinement even with identical scalar norms. artist = ax.imshow(raster[field], extent=bounds, origin="lower", interpolation="none", norm=norm, cmap=cmap, rasterized=True) bar = figure.colorbar(artist, ax=ax, shrink=.82, label="model field units") - ticks = bar.get_ticks() - ticks = ticks[(ticks >= norm.vmin) & (ticks <= norm.vmax)] - bar.set_ticks(np.unique(np.r_[norm.vmin, ticks, norm.vmax])) + # Space labels in color coordinates so endpoints never crowd an + # automatic tick. Inverting TwoSlopeNorm retains zero at the center + # while labeling both unequal ranges with their actual field values. + ticks = norm.inverse(np.linspace(0., 1., 5)) + bar.set_ticks(ticks, labels=[f"{value:.5g}" for value in ticks]) ax.set_title(f"{name}\nsampled min {values.min():.5g}; max {values.max():.5g}\n{note}", fontsize=10) else: ax.set_title(name)