8000 colormap fix mpl v3.8 · proplot-dev/proplot@df85630 · GitHub
[go: up one dir, main page]

Skip to content

Commit df85630

Browse files
committed
colormap fix mpl v3.8
1 parent 29bc955 commit df85630

File tree

6 files changed

+1949
-1908
lines changed

6 files changed

+1949
-1908
lines changed

proplot/__init__.py

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,60 @@
44
"""
55
# SCM versioning
66
import pkg_resources as pkg
7-
name = 'proplot'
7+
8+
name = "proplot"
89
try:
910
version = __version__ = pkg.get_distribution(__name__).version
1011
except pkg.DistributionNotFound:
11-
version = __version__ = 'unknown'
12+
version = __version__ = "unknown"
1213

1314
# Import dependencies early to isolate import times
1415
from . import internals, externals, tests # noqa: F401
1516
from .internals.benchmarks import _benchmark
16-
with _benchmark('pyplot'):
17+
18+
with _benchmark("pyplot"):
1719
from matplotlib import pyplot # noqa: F401
18-
with _benchmark('cartopy'):
20+
with _benchmark("cartopy"):
1921
try:
2022
import cartopy # noqa: F401
2123
except ImportError:
2224
pass
23-
with _benchmark('basemap'):
25+
with _benchmark("basemap"):
2426
try:
2527
from mpl_toolkits import basemap # noqa: F401
2628
except ImportError:
2729
pass
2830

2931
# Import everything to top level
30-
with _benchmark('config'):
32+
with _benchmark("config"):
3133
from .config import * # noqa: F401 F403
32-
with _benchmark('proj'):
34+
with _benchmark("proj"):
3335
from .proj import * # noqa: F401 F403
34-
with _benchmark('utils'):
36+
with _benchmark("utils"):
3537
from .utils import * # noqa: F401 F403
36-
with _benchmark('colors'):
38+
with _benchmark("colors"):
3739
from .colors import * # noqa: F401 F403
38-
with _benchmark('ticker'):
40+
with _benchmark("ticker"):
3941
from .ticker import * # noqa: F401 F403
40-
with _benchmark('scale'):
42+
with _benchmark("scale"):
4143
from .scale import * # noqa: F401 F403
42-
with _benchmark('axes'):
44+
with _benchmark("axes"):
4345
from .axes import * # noqa: F401 F403
44-
with _benchmark('gridspec'):
46+
with _benchmark("gridspec"):
4547
from .gridspec import * # noqa: F401 F403
46-
with _benchmark('figure'):
48+
with _benchmark("figure"):
4749
from .figure import * # noqa: F401 F403
48-
with _benchmark('constructor'):
50+
with _benchmark("constructor"):
4951
from .constructor import * # noqa: F401 F403
50-
with _benchmark('ui'):
52+
with _benchmark("ui"):
5153
from .ui import * # noqa: F401 F403
52-
with _benchmark('demos'):
54+
with _benchmark("demos"):
5355
from .demos import * # noqa: F401 F403
5456

5557
# Dynamically add registered classes to top-level namespace
5658
from . import proj as crs # backwards compatibility # noqa: F401
5759
from .constructor import NORMS, LOCATORS, FORMATTERS, SCALES, PROJS
60+
5861
_globals = globals()
5962
for _src in (NORMS, LOCATORS, FORMATTERS, SCALES, PROJS):
6063
for _key, _cls in _src.items():
@@ -63,37 +66,46 @@
6366

6467
# Register objects
6568
from .config import register_cmaps, register_cycles, register_colors, register_fonts
66-
with _benchmark('cmaps'):
69+
70+
with _benchmark("cmaps"):
6771
register_cmaps(default=True)
68-
with _benchmark('cycles'):
72+
with _benchmark("cycles"):
6973
register_cycles(default=True)
70-
with _benchmark('colors'):
74+
with _benchmark("colors"):
7175
register_colors(default=True)
72-
with _benchmark('fonts'):
76+
with _benchmark("fonts"):
7377
register_fonts(default=True)
7478

7579
# Validate colormap names and propagate 'cycle' to 'axes.prop_cycle'
7680
# NOTE: cmap.sequential also updates siblings 'cmap' and 'image.cmap'
7781
from .config import rc
7882
from .internals import rcsetup, warnings
83+
7984
rcsetup.VALIDATE_REGISTERED_CMAPS = True
80-
for _key in ('cycle', 'cmap.sequential', 'cmap.diverging', 'cmap.cyclic', 'cmap.qualitative'): # noqa: E501
85+
for _key in (
86+
"cycle",
87+
"cmap.sequential",
88+
"cmap.diverging",
89+
"cmap.cyclic",
90+
"cmap.qualitative",
91+
): # noqa: E501
8192
try:
8293
rc[_key] = rc[_key]
8394
except ValueError as err:
84-
warnings._warn_proplot(f'Invalid user rc file setting: {err}')
85-
rc[_key] = 'Greys' # fill value
95+
warnings._warn_proplot(f"Invalid user rc file setting: {err}")
96+
rc[_key] = "Greys" # fill value
8697

8798
# Validate color names now that colors are registered
8899
# NOTE: This updates all settings with 'color' in name (harmless if it's not a color)
89100
from .config import rc_proplot, rc_matplotlib
101+
90102
rcsetup.VALIDATE_REGISTERED_COLORS = True
91103
for _src in (rc_proplot, rc_matplotlib):
92104
for _key in _src: # loop through unsynced properties
93-
if 'color' not in _key:
105+
if "color" not in _key:
94106
continue
95107
try:
96108
_src[_key] = _src[_key]
97109
except ValueError as err:
98-
warnings._warn_proplot(f'Invalid user rc file setting: {err}')
99-
_src[_key] = 'black' # fill value
110+
warnings._warn_proplot(f"Invalid user rc file setting: {err}")
111+
_src[_key] = "black" # fill value

proplot/axes/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,11 +1126,13 @@ def _add_colorbar(
11261126
warnings._warn_proplot(
11271127
'Ignoring extend={extend!r}. ContourSet extend cannot be changed.'
11281128
)
1129+
11291130
if (
11301131
isinstance(locator, mticker.NullLocator)
11311132
or hasattr(locator, 'locs') and len(locator.locs) == 0
11321133
):
11331134
minorlocator, tickminor = None, False # attempted fix
1135+
11341136
for ticker in (locator, formatter, minorlocator):
11351137
if _version_mpl < '3.2':
11361138
pass # see notes above
@@ -1144,7 +1146,7 @@ def _add_colorbar(
11441146
mappable, cax=cax, ticks=locator, format=formatter,
11451147
drawedges=grid, extendfrac=extendfrac, **kwargs
11461148
)
1147-
obj.minorlocator = minorlocator # backwards compatibility
1149+
# obj.minorlocator = minorlocator # backwards compatibility NOTE: NOT sure what this does
11481150
obj.update_ticks = guides._update_ticks.__get__(obj) # backwards compatible
11491151
if minorlocator is not None:
11501152
obj.update_ticks()

0 commit comments

Comments
 (0)
0