From ad9afb2b8c6d10df669534763b58aace37316400 Mon Sep 17 00:00:00 2001 From: mkruckow <122798003+mkruckow@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:00:49 +0200 Subject: [PATCH] Update kippenhahn.py Solve some bugs for cmaps --- kippenhahn/kippenhahn.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kippenhahn/kippenhahn.py b/kippenhahn/kippenhahn.py index 9d52e23..6e53b53 100644 --- a/kippenhahn/kippenhahn.py +++ b/kippenhahn/kippenhahn.py @@ -968,7 +968,7 @@ def plot(self, ax=None): - if self._param['signed_log_cmap'] and (self._cmap_label is not None): + if self._param['signed_log_cmap'] and (self._param['cmap_label'] is not None): cmap_label = "sign x log(max(1,abs(" + cmap_label[4:]+"))" @@ -991,7 +991,7 @@ def plot(self, ax=None): if self._param['signed_log_cmap']: data_to_plot = np.sign(np.transpose(self._data)) * np.log10(np.maximum(1.,np.abs(np.transpose(self._data)))) else: - data_to_plot = np.log10(np.transpose(self._data)) + data_to_plot = np.log10(np.maximum(1e-99,np.transpose(self._data))) #Define the minimum and maximum of the color scale # When using signed_log_cmap, ignore cmap_dynamic_range @@ -1004,9 +1004,12 @@ def plot(self, ax=None): self._param['cmap_dynamic_range'] = np.nanmax(data_to_plot) - np.nanmin(data_to_plot) cmap_min = np.nanmax(data_to_plot)-self._param['cmap_dynamic_range'] cmap_max = np.nanmax(data_to_plot) - else: + elif self._param['cmap_dynamic_range']!=0: cmap_min = np.nanmax(data_to_plot)-self._param['cmap_dynamic_range'] cmap_max = np.nanmax(data_to_plot) + else: + cmap_min = np.nanmin(data_to_plot) + cmap_max = np.nanmax(data_to_plot) if ax is None: