From 72da13800ba9c8043dbc542cdb9ef85b067d2599 Mon Sep 17 00:00:00 2001 From: "marcus.wirtz" <marcus.wirtz@rwth-aachen.de> Date: Thu, 3 Sep 2020 14:09:19 +0200 Subject: [PATCH] [skymap] Optimize cbar behavior in scatter() function --- astrotools/skymap.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/astrotools/skymap.py b/astrotools/skymap.py index 7215512..e98d0ac 100644 --- a/astrotools/skymap.py +++ b/astrotools/skymap.py @@ -43,11 +43,10 @@ def scatter(v, c=None, cblabel='log$_{10}$(Energy / eV)', opath=None, fig=None, kwargs.setdefault('s', 8) if 'marker' not in kwargs: kwargs.setdefault('lw', 0) - cbar = kwargs.pop('cbar', True) + cbar = kwargs.pop('cbar', True) and isinstance(c, (list, tuple, np.ndarray)) if cbar: - finite = np.isfinite(c) - vmin = kwargs.pop('vmin', smart_round(np.min(c[finite]), upper_border=False)) - vmax = kwargs.pop('vmax', smart_round(np.max(c[finite]), upper_border=True)) + vmin = kwargs.pop('vmin', smart_round(np.min(c[np.isfinite(c)]), upper_border=False)) + vmax = kwargs.pop('vmax', smart_round(np.max(c[np.isfinite(c)]), upper_border=True)) step = smart_round((vmax - vmin) / 5., order=1) cticks = kwargs.pop('cticks', np.round(np.arange(vmin, vmax, step), int(np.round(-np.log10(step), 0)))) clabels = kwargs.pop('clabels', cticks) -- GitLab