|
4 | 4 | Implements basic shared functionality. |
5 | 5 | """ |
6 | 6 | import copy |
| 7 | +import inspect |
7 | 8 | import re |
8 | 9 | from numbers import Integral |
9 | 10 |
|
|
52 | 53 |
|
53 | 54 | # A-b-c label string |
54 | 55 | ABC_STRING = 'abcdefghijklmnopqrstuvwxyz' |
55 | | - |
56 | 56 | # Legned align options |
57 | 57 | ALIGN_OPTS = { |
58 | 58 | None: { |
|
84 | 84 | }, |
85 | 85 | } |
86 | 86 |
|
87 | | -# Axes init keys. All others are passed to format() |
88 | | -AXES_KEYS = ( |
89 | | - 'fig', |
90 | | - 'rect', |
91 | | - 'sharex', |
92 | | - 'sharey', |
93 | | - 'frameon', |
94 | | - 'box_aspect', |
95 | | - 'label', |
96 | | - 'map_projection', |
97 | | -) |
98 | | - |
99 | 87 |
|
100 | 88 | # Projection docstring |
101 | 89 | _proj_docstring = """ |
@@ -669,8 +657,12 @@ def __init__(self, *args, **kwargs): |
669 | 657 | number = kwargs.pop('number', None) |
670 | 658 | autoshare = kwargs.pop('autoshare', None) |
671 | 659 | autoshare = _not_none(autoshare, True) |
672 | | - kw_init = {key: kwargs.pop(key) for key in tuple(kwargs) if key in AXES_KEYS} |
673 | | - super().__init__(*args, **kw_init) |
| 660 | + rc_kw, rc_mode, kwargs = _parse_format(**kwargs) |
| 661 | + kw_format = {} |
| 662 | + for sig in (self._format_signature, self._format_signature_base): |
| 663 | + if sig is not None: |
| 664 | + kw_format.update(_pop_params(kwargs, sig)) |
| 665 | + super().__init__(*args, **kwargs) |
674 | 666 |
|
675 | 667 | # Varous scalar properties |
676 | 668 | self._active_cycle = rc['axes.prop_cycle'] |
@@ -737,9 +729,11 @@ def __init__(self, *args, **kwargs): |
737 | 729 | self._auto_share() |
738 | 730 |
|
739 | 731 | # Default formatting |
740 | | - # NOTE: rc_mode == 1 applies the proplot settings. This is necessary |
741 | | - # just on the first run. Default calls to format() use rc_mode == 2 |
742 | | - self.format(rc_mode=1, skip_figure=True, **kwargs) |
| 732 | + # NOTE: This ignores user-input rc_mode. Mode '1' applies proplot |
| 733 | + # features which is necessary on first run. Default otherwise is mode '2' |
| 734 | + if 'color' in rc_kw: |
| 735 | + kw_format['color'] = rc_kw.pop('color') # special case (argument clash) |
| 736 | + self.format(rc_kw=rc_kw, rc_mode=1, skip_figure=True, **kw_format) |
743 | 737 |
|
744 | 738 | @staticmethod |
745 | 739 | def _axisbelow_to_zorder(axisbelow): |
@@ -1368,7 +1362,6 @@ def _update_super_labels(self, side, labels=None, **kwargs): |
1368 | 1362 | if labels or kw: |
1369 | 1363 | fig._update_super_labels(side, labels, **kw) |
1370 | 1364 |
|
1371 | | - @docstring._obfuscate_signature |
1372 | 1365 | @docstring._snippet_manager |
1373 | 1366 | def format( |
1374 | 1367 | self, *, title=None, title_kw=None, abc_kw=None, |
@@ -1636,7 +1629,7 @@ def _add_frame( |
1636 | 1629 | patch = mpatches.FancyBboxPatch( |
1637 | 1630 | (xmin, ymin), width, height, |
1638 | 1631 | snap=True, |
1639 | | - zorder=3.5, |
| 1632 | + zorder=4.5, |
1640 | 1633 | mutation_scale=fontsize, |
1641 | 1634 | transform=self.transAxes |
1642 | 1635 | ) |
@@ -1942,8 +1935,9 @@ def _parse_inset_colorbar( |
1942 | 1935 | # Make axes and frame |
1943 | 1936 | from .cartesian import CartesianAxes |
1944 | 1937 | locator = self._make_inset_locator(ibounds, self.transAxes) |
| 1938 | + zorder = 5 # NOTE: this is identical to legend zorder |
1945 | 1939 | bbox = locator(None, None) |
1946 | | - ax = CartesianAxes(self.figure, bbox.bounds, zorder=5) |
| 1940 | + ax = CartesianAxes(self.figure, bbox.bounds, zorder=zorder) |
1947 | 1941 | ax.set_axes_locator(locator) |
1948 | 1942 | self.add_child_axes(ax) |
1949 | 1943 | kw_frame, kwargs = self._parse_frame('colorbar', **kwargs) |
@@ -2311,11 +2305,11 @@ def _draw_colorbar( |
2311 | 2305 | self._register_guide('colorbar', obj, loc) # possibly replace another |
2312 | 2306 | return obj |
2313 | 2307 |
|
2314 | | - @docstring._obfuscate_signature |
| 2308 | + @docstring._obfuscate_params |
2315 | 2309 | @docstring._snippet_manager |
2316 | 2310 | def colorbar( |
2317 | | - self, mappable, values=None, *, loc=None, location=None, queue=False, |
2318 | | - **kwargs |
| 2311 | + self, mappable, values=None, *, |
| 2312 | + loc=None, location=None, queue=False, **kwargs |
2319 | 2313 | ): |
2320 | 2314 | """ |
2321 | 2315 | Add an inset colorbar or an outer colorbar along the edge of the axes. |
@@ -2788,11 +2782,11 @@ def _draw_legend( |
2788 | 2782 | self._register_guide('legend', obj, loc) # possibly replace another |
2789 | 2783 | return obj |
2790 | 2784 |
|
2791 | | - @docstring._concatenate_original |
| 2785 | + @docstring._concatenate_inherited # also obfuscates params |
2792 | 2786 | @docstring._snippet_manager |
2793 | 2787 | def legend( |
2794 | | - self, handles=None, labels=None, *, loc=None, location=None, queue=False, |
2795 | | - **kwargs |
| 2788 | + self, handles=None, labels=None, *, |
| 2789 | + loc=None, location=None, queue=False, **kwargs |
2796 | 2790 | ): |
2797 | 2791 | """ |
2798 | 2792 | Add an *inset* legend or *outer* legend along the edge of the axes. |
@@ -2853,7 +2847,7 @@ def legend( |
2853 | 2847 | leg = self._draw_legend(handles, labels, loc=loc, **kwargs) |
2854 | 2848 | return leg |
2855 | 2849 |
|
2856 | | - @docstring._concatenate_original |
| 2850 | + @docstring._concatenate_inherited |
2857 | 2851 | @docstring._snippet_manager |
2858 | 2852 | def text( |
2859 | 2853 | self, *args, |
@@ -3029,3 +3023,9 @@ def number(self, num): |
3029 | 3023 | self._number = num |
3030 | 3024 | else: |
3031 | 3025 | raise ValueError(f'Invalid number {num!r}. Must be integer >=1.') |
| 3026 | + |
| 3027 | + # Apply signature obfuscation after getting keys |
| 3028 | + # NOTE: This is needed for __init__ |
| 3029 | + _format_signature = None |
| 3030 | + _format_signature_base = inspect.signature(format) |
| 3031 | + format = docstring._obfuscate_kwargs(format) |
0 commit comments