Skip to content

Commit

Permalink
BUG: fix a bug where setting zmin/zmax on a 2D plot with symlog norm …
Browse files Browse the repository at this point in the history
…would cause an undesired change in linthresh
  • Loading branch information
neutrinoceros committed Apr 5, 2022
1 parent a1bce43 commit f9cefde
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions yt/visualization/base_plot_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f9cefde

Please sign in to comment.