Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14d6dac

Browse files
committed
Extend _register_cmap_clip()
1 parent 79e317d commit 14d6dac

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sfs/plot2d.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
def _register_cmap_clip(name, original_cmap, alpha):
1414
"""Create a color map with "over" and "under" values."""
1515
from matplotlib.colors import LinearSegmentedColormap
16-
cdict = plt.cm.datad[original_cmap]
17-
cmap = LinearSegmentedColormap(name, cdict)
16+
cdata = plt.cm.datad[original_cmap]
17+
if isinstance(cdata, dict):
18+
cmap = LinearSegmentedColormap(name, cdata)
19+
else:
20+
cmap = LinearSegmentedColormap.from_list(name, cdata)
1821
cmap.set_over([alpha * c + 1 - alpha for c in cmap(1.0)[:3]])
1922
cmap.set_under([alpha * c + 1 - alpha for c in cmap(0.0)[:3]])
2023
plt.cm.register_cmap(cmap=cmap)

0 commit comments

Comments
 (0)