|
22 | 22 | from .internals import _not_none, docstring, warnings |
23 | 23 | from .utils import to_rgb, to_rgba, to_xyz, to_xyza |
24 | 24 |
|
25 | | -if hasattr(mcm, '_cmap_registry'): |
26 | | - _cmap_database_attr = '_cmap_registry' |
27 | | -else: |
28 | | - _cmap_database_attr = 'cmap_d' |
29 | | -_cmap_database = getattr(mcm, _cmap_database_attr) |
30 | | - |
31 | | - |
32 | 25 | __all__ = [ |
33 | 26 | 'ListedColormap', |
34 | 27 | 'LinearSegmentedColormap', |
@@ -2564,12 +2557,16 @@ def _sanitize_key(self, key, mirror=True): |
2564 | 2557 | mcolors.colorConverter.colors = _map |
2565 | 2558 |
|
2566 | 2559 | # Replace colormap database with custom database |
| 2560 | +# WARNING: Skip over the matplotlib native duplicate entries with |
| 2561 | +# suffixes '_r' and '_shifted'. |
| 2562 | +_cmap_database_attr = '_cmap_registry' if hasattr(mcm, '_cmap_registry') else 'cmap_d' |
| 2563 | +_cmap_database = getattr(mcm, _cmap_database_attr) |
2567 | 2564 | if mcm.get_cmap is not _get_cmap: |
2568 | 2565 | mcm.get_cmap = _get_cmap |
2569 | 2566 | if not isinstance(_cmap_database, ColormapDatabase): |
2570 | 2567 | _cmap_database = { |
2571 | 2568 | key: value for key, value in _cmap_database.items() |
2572 | | - if key[-2:] != '_r' and key[-2:] != '_s' |
| 2569 | + if key[-2:] != '_r' and key[-8:] != '_shifted' |
2573 | 2570 | } |
2574 | 2571 | _cmap_database = ColormapDatabase(_cmap_database) |
2575 | 2572 | setattr(mcm, _cmap_database_attr, _cmap_database) |
|
0 commit comments