Skip to content

Commit c71244c

Browse files
committed
Don't generate double-reversed cmaps ("viridis_r_r", ...).
_gen_cmap_d handles reversal of all colormaps, so _cm_listed doesn't need to generate reversed colormaps anymore -- otherwise, one gets the "double-reversed" colormaps `viridis_r_r`, etc.
1 parent 59762d4 commit c71244c

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/matplotlib/_cm_listed.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,16 +1801,13 @@
18011801
_twilight_data[:len(_twilight_data)//2])
18021802
_twilight_shifted_data.reverse()
18031803

1804-
cmaps = {}
1805-
for (name, data) in (('magma', _magma_data),
1806-
('inferno', _inferno_data),
1807-
('plasma', _plasma_data),
1808-
('viridis', _viridis_data),
1809-
('cividis', _cividis_data),
1810-
('twilight', _twilight_data),
1811-
('twilight_shifted', _twilight_shifted_data)):
1812-
1813-
cmaps[name] = ListedColormap(data, name=name)
1814-
# generate reversed colormap
1815-
name = name + '_r'
1816-
cmaps[name] = ListedColormap(list(reversed(data)), name=name)
1804+
cmaps = {
1805+
name: ListedColormap(data, name=name) for name, data in [
1806+
('magma', _magma_data),
1807+
('inferno', _inferno_data),
1808+
('plasma', _plasma_data),
1809+
('viridis', _viridis_data),
1810+
('cividis', _cividis_data),
1811+
('twilight', _twilight_data),
1812+
('twilight_shifted', _twilight_shifted_data),
1813+
]}

0 commit comments

Comments
 (0)