From 732e5b136a98ac3a63691d64af3c8526059b4307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justus=20Sagem=C3=BCller?= Date: Thu, 15 Feb 2024 16:20:44 +0100 Subject: [PATCH] Compatibility with matplotlib-3.8. The update methods for colorbars have been removed in favour of more global updates. Applying the change to the `clim`s simply on the `csub` was suggested by paulhausner in https://github.com/odlgroup/odl/pull/1635 and seems to work fine. Actually updating the drawing of the colorbar (specifically, the ticks on it) did not work with the fix suggested in the Matplotlib documentation, but `canvas.draw_idle()` does seem to have the intended effect. Fixes https://github.com/odlgroup/odl/issues/1636. --- odl/util/graphics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odl/util/graphics.py b/odl/util/graphics.py index a83dc7dfff1..98b70c884f3 100644 --- a/odl/util/graphics.py +++ b/odl/util/graphics.py @@ -436,14 +436,14 @@ def show_discrete_data(values, grid, title=None, method='', plt.colorbar(mappable=csub, ticks=ticks, format=fmt) elif update_in_place: # If it exists and we should update it - csub.colorbar.set_clim(minval, maxval) + csub.set_clim(minval, maxval) csub.colorbar.set_ticks(ticks) if '%' not in fmt: labels = [fmt] * len(ticks) else: labels = [fmt % t for t in ticks] csub.colorbar.set_ticklabels(labels) - csub.colorbar.draw_all() + fig.canvas.draw_idle() # Set title of window if title is not None: