File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,17 @@ def _gen_cmap_registry():
44
44
colors .LinearSegmentedColormap .from_list (name , spec , _LUTSIZE ))
45
45
46
46
# Register colormap aliases for gray and grey.
47
- cmap_d ['grey' ] = cmap_d ['gray' ]
48
- cmap_d ['gist_grey' ] = cmap_d ['gist_gray' ]
49
- cmap_d ['gist_yerg' ] = cmap_d ['gist_yarg' ]
50
- cmap_d ['Grays' ] = cmap_d ['Greys' ]
47
+ aliases = {
48
+ # alias -> original name
49
+ 'grey' : 'gray' ,
50
+ 'gist_grey' : 'gist_gray' ,
51
+ 'gist_yerg' : 'gist_yarg' ,
52
+ 'Grays' : 'Greys' ,
53
+ }
54
+ for alias , original_name in aliases .items ():
55
+ cmap = cmap_d [original_name ].copy ()
56
+ cmap .name = alias
57
+ cmap_d [alias ] = cmap
51
58
52
59
# Generate reversed cmaps.
53
60
for cmap in list (cmap_d .values ()):
Original file line number Diff line number Diff line change @@ -1689,6 +1689,11 @@ def test_set_cmap_mismatched_name():
1689
1689
assert cmap_returned .name == "wrong-cmap"
1690
1690
1691
1691
1692
+ def test_cmap_alias_names ():
1693
+ assert matplotlib .colormaps ["gray" ].name == "gray" # original
1694
+ assert matplotlib .colormaps ["grey" ].name == "grey" # alias
1695
+
1696
+
1692
1697
def test_to_rgba_array_none_color_with_alpha_param ():
1693
1698
# effective alpha for color "none" must always be 0 to achieve a vanishing color
1694
1699
# even explicit alpha must be ignored
You can’t perform that action at this time.
0 commit comments