Skip to content

Commit

Permalink
Compatibility with matplotlib-3.8. (#1638)
Browse files Browse the repository at this point in the history
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 #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 #1636.
  • Loading branch information
leftaroundabout authored Feb 22, 2024
1 parent c2c56d7 commit 823eea3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions odl/util/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 823eea3

Please sign in to comment.