diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py index a78e0066da0..9c51278cc1d 100644 --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -212,12 +212,10 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): cbnorm_cls = matplotlib.colors.Normalize elif cbnorm == "symlog": # if cblinthresh is not specified, try to come up with a reasonable default - vmin = float(np.nanmin(data)) - vmax = float(np.nanmax(data)) if cblinthresh is None: cblinthresh = np.nanmin(np.absolute(data)[data != 0]) - cbnorm_kwargs.update(dict(linthresh=cblinthresh, vmin=vmin, vmax=vmax)) + cbnorm_kwargs.update(dict(linthresh=cblinthresh)) MPL_VERSION = Version(matplotlib.__version__) if MPL_VERSION >= Version("3.2.0"): # note that this creates an inconsistency between mpl versions @@ -275,27 +273,30 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): if cbnorm == "symlog": formatter = matplotlib.ticker.LogFormatterMathtext(linthresh=cblinthresh) self.cb = self.figure.colorbar(self.image, self.cax, format=formatter) - if np.nanmin(data) >= 0.0: - yticks = [np.nanmin(data).v] + list( + zmin = float(self.zmin) if self.zmin is not None else np.nanmin(data) + zmax = float(self.zmax) if self.zmax is not None else np.nanmax(data) + + if zmin >= 0.0: + yticks = [zmin] + list( 10 ** np.arange( np.rint(np.log10(cblinthresh)), - np.ceil(np.log10(np.nanmax(data))), + np.ceil(np.log10(zmax)), ) ) - elif np.nanmax(data) <= 0.0: + elif zmax <= 0.0: yticks = ( list( -( 10 ** np.arange( - np.floor(np.log10(-np.nanmin(data))), + np.floor(np.log10(-zmin)), np.rint(np.log10(cblinthresh)) - 1, -1, ) ) ) - + [np.nanmax(data).v] + + [zmax] ) else: yticks = ( @@ -303,7 +304,7 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): -( 10 ** np.arange( - np.floor(np.log10(-np.nanmin(data))), + np.floor(np.log10(-zmin)), np.rint(np.log10(cblinthresh)) - 1, -1, ) @@ -314,7 +315,7 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): 10 ** np.arange( np.rint(np.log10(cblinthresh)), - np.ceil(np.log10(np.nanmax(data))), + np.ceil(np.log10(zmax)), ) ) )