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():
4444 colors .LinearSegmentedColormap .from_list (name , spec , _LUTSIZE ))
4545
4646 # 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
5158
5259 # Generate reversed cmaps.
5360 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():
16891689 assert cmap_returned .name == "wrong-cmap"
16901690
16911691
1692+ def test_cmap_alias_names ():
1693+ assert matplotlib .colormaps ["gray" ].name == "gray" # original
1694+ assert matplotlib .colormaps ["grey" ].name == "grey" # alias
1695+
1696+
16921697def test_to_rgba_array_none_color_with_alpha_param ():
16931698 # effective alpha for color "none" must always be 0 to achieve a vanishing color
16941699 # even explicit alpha must be ignored
You can’t perform that action at this time.
0 commit comments