Skip to content

Commit 559249e

Browse files
committed
Try changes from #179
1 parent 59a7ed5 commit 559249e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sfs/plot2d.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ def _register_cmap_clip(name, original_cmap, alpha):
1818
cmap = LinearSegmentedColormap.from_list(name, cdata)
1919
cmap.set_over([alpha * c + 1 - alpha for c in cmap(1.0)[:3]])
2020
cmap.set_under([alpha * c + 1 - alpha for c in cmap(0.0)[:3]])
21-
_plt.cm.register_cmap(cmap=cmap)
21+
_plt.colormaps.register(cmap=cmap)
2222

2323

2424
# The 'coolwarm' colormap is based on the paper
2525
# "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland
2626
# http://www.sandia.gov/~kmorel/documents/ColorMaps/
27-
_register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7)
27+
# already registered in MPL 3.9.0
28+
try:
29+
_register_cmap_clip('coolwarm_clip', 'coolwarm', 0.7)
30+
except ImportError:
31+
pass
2832

2933

3034
def _register_cmap_transparent(name, color):
@@ -36,7 +40,7 @@ def _register_cmap_transparent(name, color):
3640
'blue': ((0, blue, blue), (1, blue, blue)),
3741
'alpha': ((0, 0, 0), (1, 1, 1))}
3842
cmap = LinearSegmentedColormap(name, cdict)
39-
_plt.cm.register_cmap(cmap=cmap)
43+
_plt.colormaps.register(cmap=cmap)
4044

4145

4246
_register_cmap_transparent('blacktransparent', 'black')

0 commit comments

Comments
 (0)