diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index aec211d5ebb..9ab6adfaafe 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -219,18 +219,19 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): if cbnorm == "symlog": # if cblinthresh is not specified, try to come up with a reasonable default - min_abs_val, max_abs_val = np.sort(np.abs((zmin, zmax))) + min_abs_val, max_abs_val = np.sort( + np.abs((np.nanmin(data), np.nanmax(data))) + ) if cblinthresh is not None: - pass + if zmin * zmax > 0 and cblinthresh < min_abs_val: + warnings.warn( + f"Cannot set a symlog norm with linear threshold {cblinthresh} " + f"lower than the minimal absolute data value {min_abs_val} . " + "Switching to log norm." + ) + cbnorm = "log10" elif min_abs_val > 0: cblinthresh = min_abs_val - elif zmin * zmax > 0 and cblinthresh < min_abs_val: - warnings.warn( - f"Cannot set a symlog norm with linear threshold {cblinthresh} " - f"lower than the minimal absolute data value {min_abs_val} . " - "Switching to log norm." - ) - cbnorm = "log10" else: cblinthresh = max_abs_val / 1000 if cblinthresh is None: