diff --git a/eomaps/_blit_manager.py b/eomaps/_blit_manager.py index f07e7cbaa..0bf21be33 100644 --- a/eomaps/_blit_manager.py +++ b/eomaps/_blit_manager.py @@ -1413,7 +1413,13 @@ def blit_artists(self, artists, bg="active", blit=True): cv.restore_region(bg) for a in artists: - self.figure.draw_artist(a) + try: + self.figure.draw_artist(a) + except np.linalg.LinAlgError: + # Explicitly catch numpy LinAlgErrors resulting from singular matrices + # that can occur when colorbar histogram sizes are dynamically updated + if _log.getEffectiveLevel() <= logging.DEBUG: + _log.debug(f"problem drawing artist {a}", exc_info=True) if blit: cv.blit() diff --git a/eomaps/colorbar.py b/eomaps/colorbar.py index 94f53d878..9f243b066 100644 --- a/eomaps/colorbar.py +++ b/eomaps/colorbar.py @@ -255,31 +255,26 @@ def xchanged(event): self.ax_cb_plot.callbacks.connect("ylim_changed", ychanged) def _hide_singular_axes(self): - sing_hist = (self.ax_cb_plot.bbox.width <= 2) or ( self.ax_cb_plot.bbox.height <= 2 ) sing_cb = (self.ax_cb.bbox.width <= 2) or (self.ax_cb.bbox.height <= 2) - # trigger a draw to update axes positions before checking singularity - # (ignore any errors in here to avoid any remaining issues with singular axes - # if hist-updates are triggered faster than draw-events...) - try: - self._m.f.canvas.draw() - except Exception: - pass - sing_hist = (self.ax_cb_plot.bbox.width <= 2) or ( self.ax_cb_plot.bbox.height <= 2 ) sing_cb = (self.ax_cb.bbox.width <= 2) or (self.ax_cb.bbox.height <= 2) - if sing_hist: + # use additional constraint < 0.1 to re-show axes after they have been hidden + # (positions of hidden axes are not updated so we don't know the new position + # before re-drawing... and a re-draw is not wanted because it would fetch + # a new unnecessary background + if sing_hist and self._hist_size < 0.01: self.ax_cb_plot.set_visible(False) else: self.ax_cb_plot.set_visible(True) - if sing_cb: + if sing_cb and self._hist_size > 0.99: self.ax_cb.set_visible(False) else: self.ax_cb.set_visible(True) diff --git a/pyproject.toml b/pyproject.toml index fa9437b13..ff2b9f6a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ eomaps = ["logo.png", "NE_features.json", "qtcompanion/icons/*"] [project] name = "eomaps" -version = "8.1" +version = "8.1.1" description = "A library to create interactive maps of geographical datasets." readme = "README.md" license = {file = "LICENSE"}