Skip to content

Commit 056a2e3

Browse files
committed
Make Colormap() constructor permit base mcolors.Colormap
1 parent e8214b3 commit 056a2e3

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

proplot/colors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,8 @@ def __setitem__(self, key, item):
22902290
item = ListedColormap(
22912291
item.colors, item.name, item.N
22922292
)
2293+
elif isinstance(item, mcolors.Colormap): # base class
2294+
pass
22932295
else:
22942296
raise ValueError(
22952297
f'Invalid colormap {item}. Must be instance of '

proplot/constructor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ def _parse_modification(key, value):
476476
cmap = pcolors.ListedColormap(
477477
arg.colors, arg.name, arg.N
478478
)
479+
elif isinstance(arg, mcolors.Colormap): # base class
480+
cmap = arg
479481

480482
# Dictionary of hue/sat/luminance values or 2-tuples
481483
elif isinstance(arg, dict):

0 commit comments

Comments
 (0)