From 559249ea30fec72b8b3cb6803f2d2a9be29220f2 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Mon, 16 Sep 2024 16:43:12 +0200 Subject: [PATCH] Try changes from #179 --- sfs/plot2d.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sfs/plot2d.py b/sfs/plot2d.py index efadb9c..804c365 100644 --- a/sfs/plot2d.py +++ b/sfs/plot2d.py @@ -18,13 +18,17 @@ def _register_cmap_clip(name, original_cmap, alpha): cmap = LinearSegmentedColormap.from_list(name, cdata) cmap.set_over([alpha * c + 1 - alpha for c in cmap(1.0)[:3]]) cmap.set_under([alpha * c + 1 - alpha for c in cmap(0.0)[:3]]) - _plt.cm.register_cmap(cmap=cmap) + _plt.colormaps.register(cmap=cmap) # The 'coolwarm' colormap is based on the paper # "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland # http://www.sandia.gov/~kmorel/documents/ColorMaps/ -_register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7) +# already registered in MPL 3.9.0 +try: + _register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7) +except ImportError: + pass def _register_cmap_transparent(name, color): @@ -36,7 +40,7 @@ def _register_cmap_transparent(name, color): 'blue': ((0, blue, blue), (1, blue, blue)), 'alpha': ((0, 0, 0), (1, 1, 1))} cmap = LinearSegmentedColormap(name, cdict) - _plt.cm.register_cmap(cmap=cmap) + _plt.colormaps.register(cmap=cmap) _register_cmap_transparent('blacktransparent', 'black')