diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f77703c3..7305cc1b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ # WARNING: Make sure to keep flags in sync with ci/run-linter.sh repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 + rev: v4.1.0 hooks: - id: double-quote-string-fixer - id: check-docstring-first @@ -12,28 +12,28 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-isort - rev: v4.3.21 + rev: v5.10.1 hooks: - id: isort args: ['--line-width=88', '--multi-line=3', '--force-grid-wrap=0', '--trailing-comma'] exclude: '(^docs|__init__)' - repo: https://github.com/PyCQA/flake8 - rev: 3.8.3 + rev: 4.0.1 hooks: - id: flake8 args: ['--max-line-length=88', '--ignore=W503,E402,E741'] # apply once this handles long tables better # - repo: https://github.com/PyCQA/doc8 - # rev: 0.8.1 + # rev: 0.10.1 # hooks: # - id: doc8 # args: ['--max-line-length', '88', '--allow-long-titles'] # apply after function keyword args can be ignored # - repo: https://github.com/ambv/black - # rev: 19.10 + # rev: 22.1.0 # hooks: # - id: black # args: ['--line-length', '88', '--skip-string-normalization'] diff --git a/WHATSNEW.rst b/WHATSNEW.rst index 2063630e6..75ff74653 100644 --- a/WHATSNEW.rst +++ b/WHATSNEW.rst @@ -225,7 +225,11 @@ Bug fixes arrays to plotting methods (:issue:`320`). * Fix issue where list-of-string colors passed to `~proplot.axes.Axes.scatter` are interpreted as data values (:issue:`316`). -* Fix issue where settings passed to `~proplot.axes.Axes.colorbar` after e.g. +* Fix issue where *x* and *y* axis limits are reversed when passing to + `~matplotlib.axes.Axes.hexbin` and `~matplotlib.axes.Axes.hist2d` (:issue:`334`). +* Fix regression where *x* or *y* axis limits are reversed when passing to + `~matplotlib.axes.Axes.hist` and `~matplotlib.axes.Axes.histh` (:issue:`334`). +* Fix issue where settings passed to `~proplot.axes.Axes.colorbar` after calling e.g. `~proplot.axes.PlotAxes.pcolor` with `colorbar_kw` are ignored (:issue:`314`). * Fix issues where passing the colorbar `orientation` without a `loc`, or using a non- standard `orientation` for a given `loc`, triggers tickloc error (:issue:`314`). diff --git a/ci/environment.yml b/ci/environment.yml index e161ddd37..be23bffd8 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -22,7 +22,7 @@ dependencies: - pip: - .. - flake8 - - isort==4.3.21 + - isort - black - doc8 - pytest diff --git a/proplot/axes/base.py b/proplot/axes/base.py index 88af15ad3..82a12cb8e 100644 --- a/proplot/axes/base.py +++ b/proplot/axes/base.py @@ -1175,8 +1175,9 @@ def _add_colorbar( if obj.dividers is not None: obj.dividers.update(kw_outline) if obj.solids: + from . import PlotAxes obj.solids.set_rasterized(rasterized) - cax._fix_patch_edges(obj.solids, edgefix=edgefix) + PlotAxes._fix_patch_edges(obj.solids, edgefix=edgefix) # Register location and return self._register_guide('colorbar', obj, (loc, align)) # possibly replace another diff --git a/proplot/axes/geo.py b/proplot/axes/geo.py index ceb853c39..dc98551c0 100644 --- a/proplot/axes/geo.py +++ b/proplot/axes/geo.py @@ -609,6 +609,10 @@ def format( rc_kw['grid.labelweight'] = labelweight with rc.context(rc_kw, mode=rc_mode): # Apply extent mode first + # NOTE: We deprecate autoextent on _CartopyAxes with _rename_kwargs which + # does not translate boolean flag. So here apply translation. + if extent is not None and not isinstance(extent, str): + extent = ('globe', 'auto')[int(bool(extent))] self._update_boundary(round) self._update_extent_mode(extent, boundinglat) diff --git a/proplot/axes/plot.py b/proplot/axes/plot.py index 3471859be..941a7aad7 100644 --- a/proplot/axes/plot.py +++ b/proplot/axes/plot.py @@ -1272,7 +1272,7 @@ def __init__(self, *args, **kwargs): """ super().__init__(*args, **kwargs) - def _plot_native(self, name, *args, **kwargs): + def _call_native(self, name, *args, **kwargs): """ Call the plotting method and redirect internal calls to native methods. """ @@ -1287,7 +1287,7 @@ def _plot_native(self, name, *args, **kwargs): obj = getattr(super(), name)(*args, **kwargs) return obj - def _plot_negpos( + def _call_negpos( self, name, x, *ys, negcolor=None, poscolor=None, colorkey='facecolor', use_where=False, use_zero=False, **kwargs ): @@ -1311,7 +1311,7 @@ def _plot_negpos( else: yneg = inputs._safe_mask(ys[1] < ys[0], *ys) kwargs[colorkey] = _not_none(negcolor, rc['negcolor']) - negobj = self._plot_native(name, x, *yneg, **kwargs) + negobj = self._call_native(name, x, *yneg, **kwargs) # Positive component ypos = list(ys) # copy if use_zero: # filter bar heights @@ -1321,7 +1321,7 @@ def _plot_negpos( else: ypos = inputs._safe_mask(ys[1] >= ys[0], *ys) kwargs[colorkey] = _not_none(poscolor, rc['poscolor']) - posobj = self._plot_native(name, x, *ypos, **kwargs) + posobj = self._call_native(name, x, *ypos, **kwargs) return cbook.silent_list(type(negobj).__name__, (negobj, posobj)) def _add_auto_labels( @@ -1633,9 +1633,26 @@ def _fix_contour_edges(self, method, *args, **kwargs): kwargs.setdefault('linewidths', EDGEWIDTH) kwargs.pop('cmap', None) kwargs['colors'] = kwargs.pop('edgecolors', 'k') - return self._plot_native(method, *args, **kwargs) + return self._call_native(method, *args, **kwargs) - def _fix_patch_edges(self, obj, edgefix=None, **kwargs): + def _fix_sticky_edges(self, objs, axis, *args, only=None): + """ + Fix sticky edges for the input artists using the minimum and maximum of the + input coordinates. This is used to copy `bar` behavior to `area` and `lines`. + """ + for array in args: + min_, max_ = inputs._safe_range(array) + if min_ is None or max_ is None: + continue + for obj in guides._iter_iterables(objs): + if only and not isinstance(obj, only): + continue # e.g. ignore error bars + convert = getattr(self, 'convert_' + axis + 'units') + edges = getattr(obj.sticky_edges, axis) + edges.extend(convert((min_, max_))) + + @staticmethod + def _fix_patch_edges(obj, edgefix=None, **kwargs): """ Fix white lines between between filled patches and fix issues with colormaps that are transparent. If keyword args passed by user @@ -1684,26 +1701,10 @@ def _fix_patch_edges(self, obj, edgefix=None, **kwargs): obj.set_edgecolor(obj.get_facecolor()) elif np.iterable(obj): # e.g. silent_list of BarContainer for element in obj: - self._fix_patch_edges(element, edgefix=edgefix) + PlotAxes._fix_patch_edges(element, edgefix=edgefix) else: warnings._warn_proplot(f'Unexpected obj {obj} passed to _fix_patch_edges.') - def _fix_sticky_edges(self, objs, axis, *args, only=None): - """ - Fix sticky edges for the input artists using the minimum and maximum of the - input coordinates. This is used to copy `bar` behavior to `area` and `lines`. - """ - for array in args: - min_, max_ = inputs._safe_range(array) - if min_ is None or max_ is None: - continue - for obj in guides._iter_iterables(objs): - if only and not isinstance(obj, only): - continue # e.g. ignore error bars - convert = getattr(self, 'convert_' + axis + 'units') - edges = getattr(obj.sticky_edges, axis) - edges.extend(convert((min_, max_))) - @contextlib.contextmanager def _keep_grid_bools(self): """ @@ -1826,6 +1827,35 @@ def _inbounds_xylim(self, extents, x, y, **kwargs): f'data within locked x (y) limits only. Error message: {err}' ) + def _parse_1d_args(self, x, *ys, **kwargs): + """ + Interpret positional arguments for all 1D plotting commands. + """ + # Standardize values + zerox = not ys + if zerox or all(y is None for y in ys): # pad with remaining Nones + x, *ys = None, x, *ys[1:] + if len(ys) == 2: # 'lines' or 'fill_between' + if ys[1] is None: + ys = (np.array([0.0]), ys[0]) # user input 1 or 2 positional args + elif ys[0] is None: + ys = (np.array([0.0]), ys[1]) # user input keyword 'y2' but no y1 + if any(y is None for y in ys): + raise ValueError('Missing required data array argument.') + ys = tuple(map(inputs._to_duck_array, ys)) + if x is not None: + x = inputs._to_duck_array(x) + x, *ys, kwargs = self._parse_1d_format(x, *ys, zerox=zerox, **kwargs) + + # Geographic corrections + if self._name == 'cartopy' and isinstance(kwargs.get('transform'), PlateCarree): # noqa: E501 + x, *ys = inputs._geo_cartopy_1d(x, *ys) + elif self._name == 'basemap' and kwargs.get('latlon', None): + xmin, xmax = self._lonaxis.get_view_interval() + x, *ys = inputs._geo_basemap_1d(x, *ys, xmin=xmin, xmax=xmax) + + return (x, *ys, kwargs) + def _parse_1d_format( self, x, *ys, zerox=False, autox=True, autoy=True, autoformat=None, autoreverse=True, autolabels=True, autovalues=False, autoguide=True, @@ -1930,34 +1960,54 @@ def _parse_1d_format( x = inputs._to_numpy_array(x) return (x, *ys, kwargs) - def _parse_1d_plot(self, x, *ys, **kwargs): + def _parse_2d_args( + self, x, y, *zs, globe=False, edges=False, allow1d=False, + transpose=None, order=None, **kwargs + ): """ - Interpret positional arguments for all 1D plotting commands. + Interpret positional arguments for all 2D plotting commands. """ # Standardize values - zerox = not ys - if zerox or all(y is None for y in ys): # pad with remaining Nones - x, *ys = None, x, *ys[1:] - if len(ys) == 2: # 'lines' or 'fill_between' - if ys[1] is None: - ys = (np.array([0.0]), ys[0]) # user input 1 or 2 positional args - elif ys[0] is None: - ys = (np.array([0.0]), ys[1]) # user input keyword 'y2' but no y1 - if any(y is None for y in ys): - raise ValueError('Missing required data array argument.') - ys = tuple(map(inputs._to_duck_array, ys)) + # NOTE: Functions pass two 'zs' at most right now + if all(z is None for z in zs): + x, y, zs = None, None, (x, y)[:len(zs)] + if any(z is None for z in zs): + raise ValueError('Missing required data array argument(s).') + zs = tuple(inputs._to_duck_array(z, strip_units=True) for z in zs) if x is not None: x = inputs._to_duck_array(x) - x, *ys, kwargs = self._parse_1d_format(x, *ys, zerox=zerox, **kwargs) + if y is not None: + y = inputs._to_duck_array(y) + if order is not None: + if not isinstance(order, str) or order not in 'CF': + raise ValueError(f"Invalid order={order!r}. Options are 'C' or 'F'.") + transpose = _not_none( + transpose=transpose, transpose_order=bool('CF'.index(order)) + ) + if transpose: + zs = tuple(z.T for z in zs) + if x is not None: + x = x.T + if y is not None: + y = y.T + x, y, *zs, kwargs = self._parse_2d_format(x, y, *zs, **kwargs) + if edges: + # NOTE: These functions quitely pass through 1D inputs, e.g. barb data + x, y = inputs._to_edges(x, y, zs[0]) + else: + x, y = inputs._to_centers(x, y, zs[0]) # Geographic corrections - if self._name == 'cartopy' and isinstance(kwargs.get('transform'), PlateCarree): # noqa: E501 - x, *ys = inputs._geo_cartopy_1d(x, *ys) + if allow1d: + pass + elif self._name == 'cartopy' and isinstance(kwargs.get('transform'), PlateCarree): # noqa: E501 + x, y, *zs = inputs._geo_cartopy_2d(x, y, *zs, globe=globe) elif self._name == 'basemap' and kwargs.get('latlon', None): xmin, xmax = self._lonaxis.get_view_interval() - x, *ys = inputs._geo_basemap_1d(x, *ys, xmin=xmin, xmax=xmax) + x, y, *zs = inputs._geo_basemap_2d(x, y, *zs, xmin=xmin, xmax=xmax, globe=globe) # noqa: E501 + x, y = np.meshgrid(x, y) # WARNING: required always - return (x, *ys, kwargs) + return (x, y, *zs, kwargs) def _parse_2d_format( self, x, y, *zs, autoformat=None, autoguide=True, autoreverse=True, **kwargs @@ -2015,55 +2065,6 @@ def _parse_2d_format( zs = tuple(map(inputs._to_numpy_array, zs)) return (x, y, *zs, kwargs) - def _parse_2d_plot( - self, x, y, *zs, globe=False, edges=False, allow1d=False, - transpose=None, order=None, **kwargs - ): - """ - Interpret positional arguments for all 2D plotting commands. - """ - # Standardize values - # NOTE: Functions pass two 'zs' at most right now - if all(z is None for z in zs): - x, y, zs = None, None, (x, y)[:len(zs)] - if any(z is None for z in zs): - raise ValueError('Missing required data array argument(s).') - zs = tuple(inputs._to_duck_array(z, strip_units=True) for z in zs) - if x is not None: - x = inputs._to_duck_array(x) - if y is not None: - y = inputs._to_duck_array(y) - if order is not None: - if not isinstance(order, str) or order not in 'CF': - raise ValueError(f"Invalid order={order!r}. Options are 'C' or 'F'.") - transpose = _not_none( - transpose=transpose, transpose_order=bool('CF'.index(order)) - ) - if transpose: - zs = tuple(z.T for z in zs) - if x is not None: - x = x.T - if y is not None: - y = y.T - x, y, *zs, kwargs = self._parse_2d_format(x, y, *zs, **kwargs) - if edges: - # NOTE: These functions quitely pass through 1D inputs, e.g. barb data - x, y = inputs._to_edges(x, y, zs[0]) - else: - x, y = inputs._to_centers(x, y, zs[0]) - - # Geographic corrections - if allow1d: - pass - elif self._name == 'cartopy' and isinstance(kwargs.get('transform'), PlateCarree): # noqa: E501 - x, y, *zs = inputs._geo_cartopy_2d(x, y, *zs, globe=globe) - elif self._name == 'basemap' and kwargs.get('latlon', None): - xmin, xmax = self._lonaxis.get_view_interval() - x, y, *zs = inputs._geo_basemap_2d(x, y, *zs, xmin=xmin, xmax=xmax, globe=globe) # noqa: E501 - x, y = np.meshgrid(x, y) # WARNING: required always - - return (x, y, *zs, kwargs) - def _parse_color(self, x, y, c, *, apply_cycle=True, infer_rgb=False, **kwargs): """ Parse either a colormap or color cycler. Colormap will be discrete and fade @@ -2823,7 +2824,7 @@ def _apply_plot(self, *pairs, vert=True, **kwargs): kws.update(_pop_props(kws, 'line')) kws, extents = self._inbounds_extent(**kws) for xs, ys, fmt in self._iter_arg_pairs(*pairs): - xs, ys, kw = self._parse_1d_plot(xs, ys, vert=vert, **kws) + xs, ys, kw = self._parse_1d_args(xs, ys, vert=vert, **kws) ys, kw = inputs._dist_reduce(ys, **kw) guide_kw = _pop_params(kw, self._update_guide) # after standardize for _, n, x, y, kw in self._iter_arg_cols(xs, ys, **kw): @@ -2836,7 +2837,7 @@ def _apply_plot(self, *pairs, vert=True, **kwargs): a = [x, y] if fmt is not None: # x1, y1, fmt1, x2, y2, fm2... style input a.append(fmt) - obj, = self._plot_native('plot', *a, **kw) + obj, = self._call_native('plot', *a, **kw) self._inbounds_xylim(extents, x, y) objs.append((*eb, *es, obj) if eb or es else obj) @@ -2859,7 +2860,7 @@ def linex(self, *args, **kwargs): """ return self.plotx(*args, **kwargs) - @inputs._redirect_or_preprocess('x', 'y', allow_extra=True) + @inputs._preprocess_or_redirect('x', 'y', allow_extra=True) @docstring._concatenate_inherited @docstring._snippet_manager def plot(self, *args, **kwargs): @@ -2869,7 +2870,7 @@ def plot(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_plot(*args, **kwargs) - @inputs._redirect_or_preprocess('y', 'x', allow_extra=True) + @inputs._preprocess_or_redirect('y', 'x', allow_extra=True) @docstring._snippet_manager def plotx(self, *args, **kwargs): """ @@ -2895,7 +2896,7 @@ def _apply_step(self, *pairs, vert=True, where='pre', **kwargs): kws, extents = self._inbounds_extent(**kws) objs = [] for xs, ys, fmt in self._iter_arg_pairs(*pairs): - xs, ys, kw = self._parse_1d_plot(xs, ys, vert=vert, **kws) + xs, ys, kw = self._parse_1d_args(xs, ys, vert=vert, **kws) guide_kw = _pop_params(kw, self._update_guide) # after standardize if fmt is not None: kw['fmt'] = fmt @@ -2903,14 +2904,14 @@ def _apply_step(self, *pairs, vert=True, where='pre', **kwargs): kw = self._parse_cycle(n, **kw) if not vert: x, y = y, x - obj, = self._plot_native('step', x, y, *a, **kw) + obj, = self._call_native('step', x, y, *a, **kw) self._inbounds_xylim(extents, x, y) objs.append(obj) self._update_guide(objs, **guide_kw) return cbook.silent_list('Line2D', objs) # always return list - @inputs._redirect_or_preprocess('x', 'y', allow_extra=True) + @inputs._preprocess_or_redirect('x', 'y', allow_extra=True) @docstring._concatenate_inherited @docstring._snippet_manager def step(self, *args, **kwargs): @@ -2920,7 +2921,7 @@ def step(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_step(*args, **kwargs) - @inputs._redirect_or_preprocess('y', 'x', allow_extra=True) + @inputs._preprocess_or_redirect('y', 'x', allow_extra=True) @docstring._snippet_manager def stepx(self, *args, **kwargs): """ @@ -2939,7 +2940,7 @@ def _apply_stem( # Parse input kw = kwargs.copy() kw, extents = self._inbounds_extent(**kw) - x, y, kw = self._parse_1d_plot(x, y, **kw) + x, y, kw = self._parse_1d_args(x, y, **kw) guide_kw = _pop_params(kw, self._update_guide) # Set default colors @@ -2970,12 +2971,12 @@ def _apply_stem( if orientation == 'horizontal': # may raise error kw['orientation'] = orientation with rc.context(ctx): - obj = self._plot_native('stem', x, y, **kw) + obj = self._call_native('stem', x, y, **kw) self._inbounds_xylim(extents, x, y, orientation=orientation) self._update_guide(obj, **guide_kw) return obj - @inputs._redirect_or_preprocess('x', 'y') + @inputs._preprocess_or_redirect('x', 'y') @docstring._concatenate_inherited @docstring._snippet_manager def stem(self, *args, **kwargs): @@ -2985,7 +2986,7 @@ def stem(self, *args, **kwargs): kwargs = _parse_vert(default_orientation='vertical', **kwargs) return self._apply_stem(*args, **kwargs) - @inputs._redirect_or_preprocess('x', 'y') + @inputs._preprocess_or_redirect('x', 'y') @docstring._snippet_manager def stemx(self, *args, **kwargs): """ @@ -2994,7 +2995,7 @@ def stemx(self, *args, **kwargs): kwargs = _parse_vert(default_orientation='horizontal', **kwargs) return self._apply_stem(*args, **kwargs) - @inputs._redirect_or_preprocess('x', 'y', ('c', 'color', 'colors', 'values')) + @inputs._preprocess_or_redirect('x', 'y', ('c', 'color', 'colors', 'values')) @docstring._snippet_manager def parametric(self, x, y, c, *, interp=0, scalex=True, scaley=True, **kwargs): """ @@ -3009,7 +3010,9 @@ def parametric(self, x, y, c, *, interp=0, scalex=True, scaley=True, **kwargs): kw.update(_pop_props(kw, 'collection')) kw, extents = self._inbounds_extent(**kw) label = _not_none(**{key: kw.pop(key, None) for key in ('label', 'value')}) - x, y, kw = self._parse_1d_plot(x, y, values=c, autovalues=True, autoreverse=False, **kw) # noqa: E501 + x, y, kw = self._parse_1d_args( + x, y, values=c, autovalues=True, autoreverse=False, **kw + ) c = kw.pop('values', None) # permits auto-inferring values c = np.arange(y.size) if c is None else inputs._to_numpy_array(c) if ( @@ -3096,7 +3099,7 @@ def _apply_lines( kw.update(_pop_props(kw, 'collection')) kw, extents = self._inbounds_extent(**kw) stack = _not_none(stack=stack, stacked=stacked) - xs, ys1, ys2, kw = self._parse_1d_plot(xs, ys1, ys2, vert=vert, **kw) + xs, ys1, ys2, kw = self._parse_1d_args(xs, ys1, ys2, vert=vert, **kw) guide_kw = _pop_params(kw, self._update_guide) # Support "negative" and "positive" lines @@ -3111,9 +3114,9 @@ def _apply_lines( y2 = y2 + y0 y0 = y0 + y2 - y1 # irrelevant that we added y0 to both if negpos: - obj = self._plot_negpos(name, x, y1, y2, colorkey='colors', **kw) + obj = self._call_negpos(name, x, y1, y2, colorkey='colors', **kw) else: - obj = self._plot_native(name, x, y1, y2, **kw) + obj = self._call_native(name, x, y1, y2, **kw) for y in (y1, y2): self._inbounds_xylim(extents, x, y, vert=vert) if y.size == 1: # add sticky edges if bounds are scalar @@ -3129,7 +3132,7 @@ def _apply_lines( ) # WARNING: breaking change from native 'ymin' and 'ymax' - @inputs._redirect_or_preprocess('x', 'y1', 'y2', ('c', 'color', 'colors')) + @inputs._preprocess_or_redirect('x', 'y1', 'y2', ('c', 'color', 'colors')) @docstring._snippet_manager def vlines(self, *args, **kwargs): """ @@ -3139,7 +3142,7 @@ def vlines(self, *args, **kwargs): return self._apply_lines(*args, **kwargs) # WARNING: breaking change from native 'xmin' and 'xmax' - @inputs._redirect_or_preprocess('y', 'x1', 'x2', ('c', 'color', 'colors')) + @inputs._preprocess_or_redirect('y', 'x1', 'x2', ('c', 'color', 'colors')) @docstring._snippet_manager def hlines(self, *args, **kwargs): """ @@ -3199,7 +3202,7 @@ def _apply_scatter(self, xs, ys, ss, cc, *, vert=True, **kwargs): inbounds = kw.pop('inbounds', None) kw.update(_pop_props(kw, 'collection')) kw, extents = self._inbounds_extent(inbounds=inbounds, **kw) - xs, ys, kw = self._parse_1d_plot(xs, ys, vert=vert, autoreverse=False, **kw) + xs, ys, kw = self._parse_1d_args(xs, ys, vert=vert, autoreverse=False, **kw) ys, kw = inputs._dist_reduce(ys, **kw) ss, kw = self._parse_markersize(ss, **kw) # parse 's' infer_rgb = True @@ -3222,7 +3225,7 @@ def _apply_scatter(self, xs, ys, ss, cc, *, vert=True, **kwargs): *es, kw = self._add_error_shading(x, y, vert=vert, color_key='c', **kw) if not vert: x, y = y, x - obj = self._plot_native('scatter', x, y, **kw) + obj = self._call_native('scatter', x, y, **kw) self._inbounds_xylim(extents, x, y) objs.append((*eb, *es, obj) if eb or es else obj) @@ -3235,7 +3238,7 @@ def _apply_scatter(self, xs, ys, ss, cc, *, vert=True, **kwargs): # NOTE: Matplotlib internally applies scatter 'c' arguments as the # 'facecolors' argument to PathCollection. So perfectly reasonable to # point both 'color' and 'facecolor' arguments to the 'c' keyword here. - @inputs._redirect_or_preprocess( + @inputs._preprocess_or_redirect( 'x', 'y', _get_aliases('collection', 'sizes'), @@ -3251,7 +3254,7 @@ def scatter(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_scatter(*args, **kwargs) - @inputs._redirect_or_preprocess( + @inputs._preprocess_or_redirect( 'y', 'x', _get_aliases('collection', 'sizes'), @@ -3279,7 +3282,7 @@ def _apply_fill( kw, extents = self._inbounds_extent(**kw) name = 'fill_between' if vert else 'fill_betweenx' stack = _not_none(stack=stack, stacked=stacked) - xs, ys1, ys2, kw = self._parse_1d_plot(xs, ys1, ys2, vert=vert, **kw) + xs, ys1, ys2, kw = self._parse_1d_args(xs, ys1, ys2, vert=vert, **kw) edgefix_kw = _pop_params(kw, self._fix_patch_edges) # Draw patches with default edge width zero @@ -3293,9 +3296,9 @@ def _apply_fill( y2 = y2 + y0 y0 = y0 + y2 - y1 # irrelevant that we added y0 to both if negpos: # NOTE: if user passes 'where' will issue a warning - obj = self._plot_negpos(name, x, y1, y2, where=w, use_where=True, **kw) # noqa: E501 + obj = self._call_negpos(name, x, y1, y2, where=w, use_where=True, **kw) else: - obj = self._plot_native(name, x, y1, y2, where=w, **kw) + obj = self._call_native(name, x, y1, y2, where=w, **kw) self._fix_patch_edges(obj, **edgefix_kw, **kw) xsides.append(x) for y in (y1, y2): @@ -3327,7 +3330,7 @@ def areax(self, *args, **kwargs): """ return self.fill_betweenx(*args, **kwargs) - @inputs._redirect_or_preprocess('x', 'y1', 'y2', 'where') + @inputs._preprocess_or_redirect('x', 'y1', 'y2', 'where') @docstring._concatenate_inherited @docstring._snippet_manager def fill_between(self, *args, **kwargs): @@ -3337,7 +3340,7 @@ def fill_between(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_fill(*args, **kwargs) - @inputs._redirect_or_preprocess('y', 'x1', 'x2', 'where') + @inputs._preprocess_or_redirect('y', 'x1', 'x2', 'where') @docstring._concatenate_inherited @docstring._snippet_manager def fill_betweenx(self, *args, **kwargs): @@ -3382,7 +3385,7 @@ def _apply_bar( kw, extents = self._inbounds_extent(**kw) name = 'barh' if orientation == 'horizontal' else 'bar' stack = _not_none(stack=stack, stacked=stacked) - xs, hs, kw = self._parse_1d_plot(xs, hs, orientation=orientation, **kw) + xs, hs, kw = self._parse_1d_args(xs, hs, orientation=orientation, **kw) edgefix_kw = _pop_params(kw, self._fix_patch_edges) if absolute_width is None: absolute_width = _inside_seaborn_call() @@ -3410,9 +3413,9 @@ def _apply_bar( # Draw simple bars *eb, kw = self._add_error_bars(x, b + h, default_barstds=True, orientation=orientation, **kw) # noqa: E501 if negpos: - obj = self._plot_negpos(name, x, h, w, b, use_zero=True, **kw) + obj = self._call_negpos(name, x, h, w, b, use_zero=True, **kw) else: - obj = self._plot_native(name, x, h, w, b, **kw) + obj = self._call_native(name, x, h, w, b, **kw) self._fix_patch_edges(obj, **edgefix_kw, **kw) for y in (b, b + h): self._inbounds_xylim(extents, x, y, orientation=orientation) @@ -3424,7 +3427,7 @@ def _apply_bar( else cbook.silent_list('BarContainer', objs) ) - @inputs._redirect_or_preprocess('x', 'height', 'width', 'bottom') + @inputs._preprocess_or_redirect('x', 'height', 'width', 'bottom') @docstring._concatenate_inherited @docstring._snippet_manager def bar(self, *args, **kwargs): @@ -3436,7 +3439,7 @@ def bar(self, *args, **kwargs): # WARNING: Swap 'height' and 'width' here so that they are always relative # to the 'tall' axis. This lets people always pass 'width' as keyword - @inputs._redirect_or_preprocess('y', 'height', 'width', 'left') + @inputs._preprocess_or_redirect('y', 'height', 'width', 'left') @docstring._concatenate_inherited @docstring._snippet_manager def barh(self, *args, **kwargs): @@ -3448,7 +3451,7 @@ def barh(self, *args, **kwargs): # WARNING: 'labels' and 'colors' no longer passed through `data` (seems like # extremely niche usage... `data` variables should be data-like) - @inputs._redirect_or_preprocess('x', 'explode') + @inputs._preprocess_or_redirect('x', 'explode') @docstring._concatenate_inherited @docstring._snippet_manager def pie(self, x, explode, *, labelpad=None, labeldistance=None, **kwargs): @@ -3457,14 +3460,18 @@ def pie(self, x, explode, *, labelpad=None, labeldistance=None, **kwargs): """ kw = kwargs.copy() pad = _not_none(labeldistance=labeldistance, labelpad=labelpad, default=1.15) - props = _pop_props(kw, 'patch') + wedge_kw = kw.pop('wedgeprops', None) or {} + wedge_kw.update(_pop_props(kw, 'patch')) edgefix_kw = _pop_params(kw, self._fix_patch_edges) - _, x, kw = self._parse_1d_plot(x, autox=False, autoy=False, **kw) + _, x, kw = self._parse_1d_args( + x, autox=False, autoy=False, autoreverse=False, **kw + ) kw = self._parse_cycle(x.size, **kw) - kw['labeldistance'] = pad - objs = self._plot_native('pie', x, explode, wedgeprops=props, **kw) + objs = self._call_native( + 'pie', x, explode, labeldistance=pad, wedgeprops=wedge_kw, **kw + ) objs = tuple(cbook.silent_list(type(seq[0]).__name__, seq) for seq in objs) - self._fix_patch_edges(objs[0], **edgefix_kw, **props) + self._fix_patch_edges(objs[0], **edgefix_kw, **wedge_kw) return objs @staticmethod @@ -3527,7 +3534,7 @@ def _apply_boxplot( iprops.setdefault('markeredgecolor', edgecolor) # Parse color properties - x, y, kw = self._parse_1d_plot( + x, y, kw = self._parse_1d_args( x, y, autoy=False, autoguide=False, vert=vert, **kw ) kw = self._parse_cycle(x.size, **kw) # possibly apply cycle @@ -3542,7 +3549,7 @@ def _apply_boxplot( if means: kw['showmeans'] = kw['meanline'] = True y = inputs._dist_clean(y) - artists = self._plot_native('boxplot', y, vert=vert, **kw) + artists = self._call_native('boxplot', y, vert=vert, **kw) artists = artists or {} # necessary? artists = { key: cbook.silent_list(type(objs[0]).__name__, objs) if objs else objs @@ -3600,7 +3607,7 @@ def boxh(self, *args, **kwargs): """ return self.boxploth(*args, **kwargs) - @inputs._redirect_or_preprocess('positions', 'y') + @inputs._preprocess_or_redirect('positions', 'y') @docstring._concatenate_inherited @docstring._snippet_manager def boxplot(self, *args, **kwargs): @@ -3610,7 +3617,7 @@ def boxplot(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_boxplot(*args, **kwargs) - @inputs._redirect_or_preprocess('positions', 'x') + @inputs._preprocess_or_redirect('positions', 'x') @docstring._snippet_manager def boxploth(self, *args, **kwargs): """ @@ -3645,7 +3652,7 @@ def _apply_violinplot( ) # Parse color properties - x, y, kw = self._parse_1d_plot( + x, y, kw = self._parse_1d_args( x, y, autoy=False, autoguide=False, vert=vert, **kw ) kw = self._parse_cycle(x.size, **kw) @@ -3658,11 +3665,11 @@ def _apply_violinplot( # Plot violins y, kw = inputs._dist_reduce(y, means=means, medians=medians, **kw) *eb, kw = self._add_error_bars(x, y, vert=vert, default_boxstds=True, default_marker=True, **kw) # noqa: E501 - kw.pop('labels', None) # already applied in _parse_1d_plot + kw.pop('labels', None) # already applied in _parse_1d_args kw.setdefault('positions', x) # coordinates passed as keyword y = _not_none(kw.pop('distribution'), y) # i.e. was reduced y = inputs._dist_clean(y) - artists = self._plot_native( + artists = self._call_native( 'violinplot', y, vert=vert, showmeans=False, showmedians=False, showextrema=False, **kw ) @@ -3703,7 +3710,7 @@ def violinh(self, *args, **kwargs): """ return self.violinploth(*args, **kwargs) - @inputs._redirect_or_preprocess('positions', 'y') + @inputs._preprocess_or_redirect('positions', 'y') @docstring._concatenate_inherited @docstring._snippet_manager def violinplot(self, *args, **kwargs): @@ -3713,7 +3720,7 @@ def violinplot(self, *args, **kwargs): kwargs = _parse_vert(default_vert=True, **kwargs) return self._apply_violinplot(*args, **kwargs) - @inputs._redirect_or_preprocess('positions', 'x') + @inputs._preprocess_or_redirect('positions', 'x') @docstring._snippet_manager def violinploth(self, *args, **kwargs): """ @@ -3734,7 +3741,9 @@ def _apply_hist( # adds them to the first elements in the container for each column # of the input data. Make sure that legend() will read both containers # and individual items inside those containers. - _, xs, kw = self._parse_1d_plot(xs, orientation=orientation, **kwargs) + _, xs, kw = self._parse_1d_args( + xs, autoreverse=False, orientation=orientation, **kwargs + ) fill = _not_none(fill=fill, filled=filled) stack = _not_none(stack=stack, stacked=stacked) if fill is not None: @@ -3750,7 +3759,7 @@ def _apply_hist( guide_kw = _pop_params(kw, self._update_guide) n = xs.shape[1] if xs.ndim > 1 else 1 kw = self._parse_cycle(n, **kw) - obj = self._plot_native('hist', xs, orientation=orientation, **kw) + obj = self._call_native('hist', xs, orientation=orientation, **kw) if histtype.startswith('bar'): self._fix_patch_edges(obj[2], **edgefix_kw, **kw) # Revert to mpl < 3.3 behavior where silent_list was always returned for @@ -3766,7 +3775,7 @@ def _apply_hist( self._update_guide(res, **guide_kw) return obj - @inputs._redirect_or_preprocess('x', 'bins', keywords='weights') + @inputs._preprocess_or_redirect('x', 'bins', keywords='weights') @docstring._concatenate_inherited @docstring._snippet_manager def hist(self, *args, **kwargs): @@ -3776,7 +3785,7 @@ def hist(self, *args, **kwargs): kwargs = _parse_vert(default_orientation='vertical', **kwargs) return self._apply_hist(*args, **kwargs) - @inputs._redirect_or_preprocess('y', 'bins', keywords='weights') + @inputs._preprocess_or_redirect('y', 'bins', keywords='weights') @docstring._snippet_manager def histh(self, *args, **kwargs): """ @@ -3785,20 +3794,20 @@ def histh(self, *args, **kwargs): kwargs = _parse_vert(default_orientation='horizontal', **kwargs) return self._apply_hist(*args, **kwargs) - @inputs._redirect_or_preprocess('x', 'y', 'bins', keywords='weights') + @inputs._preprocess_or_redirect('x', 'y', 'bins', keywords='weights') @docstring._concatenate_inherited @docstring._snippet_manager def hist2d(self, x, y, bins, **kwargs): """ %(plot.hist2d)s """ - # Rely on pcolormesh() override for this. + # Rely on the pcolormesh() override for this. if bins is not None: kwargs['bins'] = bins - return super().hist2d(x, y, default_discrete=False, **kwargs) + return super().hist2d(x, y, autoreverse=False, default_discrete=False, **kwargs) # WARNING: breaking change from native 'C' - @inputs._redirect_or_preprocess('x', 'y', 'weights') + @inputs._preprocess_or_redirect('x', 'y', 'weights') @docstring._concatenate_inherited @docstring._snippet_manager def hexbin(self, x, y, weights, **kwargs): @@ -3808,7 +3817,10 @@ def hexbin(self, x, y, weights, **kwargs): # WARNING: Cannot use automatic level generation here until counts are # estimated. Inside _parse_level_vals if no manual levels were provided then # _parse_level_num is skipped and args like levels=10 or locator=5 are ignored - x, y, kw = self._parse_1d_plot(x, y, autovalues=True, **kwargs) + kw = kwargs.copy() + x, y, kw = self._parse_1d_args( + x, y, autoreverse=False, autovalues=True, **kw + ) kw.update(_pop_props(kw, 'collection')) # takes LineCollection props kw = self._parse_cmap(x, y, y, skip_autolev=True, default_discrete=False, **kw) norm = kw.get('norm', None) @@ -3816,19 +3828,19 @@ def hexbin(self, x, y, weights, **kwargs): norm.vmin = norm.vmax = None # remove nonsense values labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) - m = self._plot_native('hexbin', x, y, weights, **kw) + m = self._call_native('hexbin', x, y, weights, **kw) self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def contour(self, x, y, z, **kwargs): """ %(plot.contour)s """ - x, y, z, kw = self._parse_2d_plot(x, y, z, **kwargs) + x, y, z, kw = self._parse_2d_args(x, y, z, **kwargs) kw.update(_pop_props(kw, 'collection')) kw = self._parse_cmap( x, y, z, min_levels=1, plot_lines=True, plot_contours=True, **kw @@ -3836,20 +3848,20 @@ def contour(self, x, y, z, **kwargs): labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) label = kw.pop('label', None) - m = self._plot_native('contour', x, y, z, **kw) + m = self._call_native('contour', x, y, z, **kw) m._legend_label = label self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def contourf(self, x, y, z, **kwargs): """ %(plot.contourf)s """ - x, y, z, kw = self._parse_2d_plot(x, y, z, **kwargs) + x, y, z, kw = self._parse_2d_args(x, y, z, **kwargs) kw.update(_pop_props(kw, 'collection')) kw = self._parse_cmap(x, y, z, plot_contours=True, **kw) contour_kw = _pop_kwargs(kw, 'edgecolors', 'linewidths', 'linestyles') @@ -3857,7 +3869,7 @@ def contourf(self, x, y, z, **kwargs): labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) label = kw.pop('label', None) - m = cm = self._plot_native('contourf', x, y, z, **kw) + m = cm = self._call_native('contourf', x, y, z, **kw) m._legend_label = label self._fix_patch_edges(m, **edgefix_kw, **contour_kw) # no-op if not contour_kw if contour_kw or labels_kw: @@ -3866,61 +3878,61 @@ def contourf(self, x, y, z, **kwargs): self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def pcolor(self, x, y, z, **kwargs): """ %(plot.pcolor)s """ - x, y, z, kw = self._parse_2d_plot(x, y, z, edges=True, **kwargs) + x, y, z, kw = self._parse_2d_args(x, y, z, edges=True, **kwargs) kw.update(_pop_props(kw, 'collection')) kw = self._parse_cmap(x, y, z, to_centers=True, **kw) edgefix_kw = _pop_params(kw, self._fix_patch_edges) labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) with self._keep_grid_bools(): - m = self._plot_native('pcolor', x, y, z, **kw) + m = self._call_native('pcolor', x, y, z, **kw) self._fix_patch_edges(m, **edgefix_kw, **kw) self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def pcolormesh(self, x, y, z, **kwargs): """ %(plot.pcolormesh)s """ - x, y, z, kw = self._parse_2d_plot(x, y, z, edges=True, **kwargs) + x, y, z, kw = self._parse_2d_args(x, y, z, edges=True, **kwargs) kw.update(_pop_props(kw, 'collection')) kw = self._parse_cmap(x, y, z, to_centers=True, **kw) edgefix_kw = _pop_params(kw, self._fix_patch_edges) labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) with self._keep_grid_bools(): - m = self._plot_native('pcolormesh', x, y, z, **kw) + m = self._call_native('pcolormesh', x, y, z, **kw) self._fix_patch_edges(m, **edgefix_kw, **kw) self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def pcolorfast(self, x, y, z, **kwargs): """ %(plot.pcolorfast)s """ - x, y, z, kw = self._parse_2d_plot(x, y, z, edges=True, **kwargs) + x, y, z, kw = self._parse_2d_args(x, y, z, edges=True, **kwargs) kw.update(_pop_props(kw, 'collection')) kw = self._parse_cmap(x, y, z, to_centers=True, **kw) edgefix_kw = _pop_params(kw, self._fix_patch_edges) labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) with self._keep_grid_bools(): - m = self._plot_native('pcolorfast', x, y, z, **kw) + m = self._call_native('pcolorfast', x, y, z, **kw) if not isinstance(m, mimage.AxesImage): # NOTE: PcolorImage is derivative self._fix_patch_edges(m, **edgefix_kw, **kw) self._add_auto_labels(m, **labels_kw) @@ -3964,14 +3976,14 @@ def heatmap(self, *args, aspect=None, **kwargs): self.format(**kw) return obj - @inputs._redirect_or_preprocess('x', 'y', 'u', 'v', ('c', 'color', 'colors')) + @inputs._preprocess_or_redirect('x', 'y', 'u', 'v', ('c', 'color', 'colors')) @docstring._concatenate_inherited @docstring._snippet_manager def barbs(self, x, y, u, v, c, **kwargs): """ %(plot.barbs)s """ - x, y, u, v, kw = self._parse_2d_plot(x, y, u, v, allow1d=True, autoguide=False, **kwargs) # noqa: E501 + x, y, u, v, kw = self._parse_2d_args(x, y, u, v, allow1d=True, autoguide=False, **kwargs) # noqa: E501 kw.update(_pop_props(kw, 'line')) # applied to barbs c, kw = self._parse_color(x, y, c, **kw) if mcolors.is_color_like(c): @@ -3980,17 +3992,17 @@ def barbs(self, x, y, u, v, c, **kwargs): if c is not None: a.append(c) kw.pop('colorbar_kw', None) # added by _parse_cmap - m = self._plot_native('barbs', *a, **kw) + m = self._call_native('barbs', *a, **kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'u', 'v', ('c', 'color', 'colors')) + @inputs._preprocess_or_redirect('x', 'y', 'u', 'v', ('c', 'color', 'colors')) @docstring._concatenate_inherited @docstring._snippet_manager def quiver(self, x, y, u, v, c, **kwargs): """ %(plot.quiver)s """ - x, y, u, v, kw = self._parse_2d_plot(x, y, u, v, allow1d=True, autoguide=False, **kwargs) # noqa: E501 + x, y, u, v, kw = self._parse_2d_args(x, y, u, v, allow1d=True, autoguide=False, **kwargs) # noqa: E501 kw.update(_pop_props(kw, 'line')) # applied to arrow outline c, kw = self._parse_color(x, y, c, **kw) color = None @@ -4002,7 +4014,7 @@ def quiver(self, x, y, u, v, c, **kwargs): if c is not None: a.append(c) kw.pop('colorbar_kw', None) # added by _parse_cmap - m = self._plot_native('quiver', *a, **kw) + m = self._call_native('quiver', *a, **kw) return m @docstring._snippet_manager @@ -4013,7 +4025,7 @@ def stream(self, *args, **kwargs): return self.streamplot(*args, **kwargs) # WARNING: breaking change from native streamplot() fifth positional arg 'density' - @inputs._redirect_or_preprocess( + @inputs._preprocess_or_redirect( 'x', 'y', 'u', 'v', ('c', 'color', 'colors'), keywords='start_points' ) @docstring._concatenate_inherited @@ -4022,7 +4034,7 @@ def streamplot(self, x, y, u, v, c, **kwargs): """ %(plot.stream)s """ - x, y, u, v, kw = self._parse_2d_plot(x, y, u, v, **kwargs) + x, y, u, v, kw = self._parse_2d_args(x, y, u, v, **kwargs) kw.update(_pop_props(kw, 'line')) # applied to lines c, kw = self._parse_color(x, y, c, **kw) if c is None: # throws an error if color not provided @@ -4030,12 +4042,12 @@ def streamplot(self, x, y, u, v, c, **kwargs): kw['color'] = c # always pass this guide_kw = _pop_params(kw, self._update_guide) label = kw.pop('label', None) - m = self._plot_native('streamplot', x, y, u, v, **kw) + m = self._call_native('streamplot', x, y, u, v, **kw) m.lines.set_label(label) # the collection label self._update_guide(m.lines, queue_colorbar=False, **guide_kw) # use lines return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def tricontour(self, x, y, z, **kwargs): @@ -4052,13 +4064,13 @@ def tricontour(self, x, y, z, **kwargs): labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) label = kw.pop('label', None) - m = self._plot_native('tricontour', x, y, z, **kw) + m = self._call_native('tricontour', x, y, z, **kw) m._legend_label = label self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def tricontourf(self, x, y, z, **kwargs): @@ -4075,7 +4087,7 @@ def tricontourf(self, x, y, z, **kwargs): labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) label = kw.pop('label', None) - m = cm = self._plot_native('tricontourf', x, y, z, **kw) + m = cm = self._call_native('tricontourf', x, y, z, **kw) m._legend_label = label self._fix_patch_edges(m, **edgefix_kw, **contour_kw) # no-op if not contour_kw if contour_kw or labels_kw: @@ -4084,7 +4096,7 @@ def tricontourf(self, x, y, z, **kwargs): self._update_guide(m, queue_colorbar=False, **guide_kw) return m - @inputs._redirect_or_preprocess('x', 'y', 'z') + @inputs._preprocess_or_redirect('x', 'y', 'z') @docstring._concatenate_inherited @docstring._snippet_manager def tripcolor(self, x, y, z, **kwargs): @@ -4100,14 +4112,14 @@ def tripcolor(self, x, y, z, **kwargs): labels_kw = _pop_params(kw, self._add_auto_labels) guide_kw = _pop_params(kw, self._update_guide) with self._keep_grid_bools(): - m = self._plot_native('tripcolor', x, y, z, **kw) + m = self._call_native('tripcolor', x, y, z, **kw) self._fix_patch_edges(m, **edgefix_kw, **kw) self._add_auto_labels(m, **labels_kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m # WARNING: breaking change from native 'X' - @inputs._redirect_or_preprocess('z') + @inputs._preprocess_or_redirect('z') @docstring._concatenate_inherited @docstring._snippet_manager def imshow(self, z, **kwargs): @@ -4117,12 +4129,12 @@ def imshow(self, z, **kwargs): kw = kwargs.copy() kw = self._parse_cmap(z, default_discrete=False, **kw) guide_kw = _pop_params(kw, self._update_guide) - m = self._plot_native('imshow', z, **kw) + m = self._call_native('imshow', z, **kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m # WARNING: breaking change from native 'Z' - @inputs._redirect_or_preprocess('z') + @inputs._preprocess_or_redirect('z') @docstring._concatenate_inherited @docstring._snippet_manager def matshow(self, z, **kwargs): @@ -4133,7 +4145,7 @@ def matshow(self, z, **kwargs): return super().matshow(z, **kwargs) # WARNING: breaking change from native 'Z' - @inputs._redirect_or_preprocess('z') + @inputs._preprocess_or_redirect('z') @docstring._concatenate_inherited @docstring._snippet_manager def spy(self, z, **kwargs): @@ -4145,7 +4157,7 @@ def spy(self, z, **kwargs): default_cmap = pcolors.DiscreteColormap(['w', 'k'], '_no_name') kw = self._parse_cmap(z, default_cmap=default_cmap, **kw) guide_kw = _pop_params(kw, self._update_guide) - m = self._plot_native('spy', z, **kw) + m = self._call_native('spy', z, **kw) self._update_guide(m, queue_colorbar=False, **guide_kw) return m @@ -4171,7 +4183,7 @@ def _iter_arg_cols(self, *args, label=None, labels=None, values=None, **kwargs): Iterate over columns of positional arguments. """ # Handle cycle args and label lists - # NOTE: Arrays here should have had metadata stripped by _parse_1d_plot + # NOTE: Arrays here should have had metadata stripped by _parse_1d_args # but could still be pint quantities that get processed by axis converter. n = max( 1 if not inputs._is_array(a) or a.ndim < 2 else a.shape[-1] diff --git a/proplot/internals/inputs.py b/proplot/internals/inputs.py index 2eed36e9e..c8a53db03 100644 --- a/proplot/internals/inputs.py +++ b/proplot/internals/inputs.py @@ -241,7 +241,7 @@ def _from_data(data, *args): return args -def _redirect_or_preprocess(*keys, keywords=None, allow_extra=True): +def _preprocess_or_redirect(*keys, keywords=None, allow_extra=True): """ Redirect internal plotting calls to native matplotlib methods. Also convert keyword args to positional and pass arguments through 'data' dictionary. @@ -257,7 +257,7 @@ def _decorator(func): from . import _kwargs_to_args @functools.wraps(func) - def _redirect_or_preprocess(self, *args, **kwargs): + def _preprocess_or_redirect(self, *args, **kwargs): if getattr(self, '_internal_call', None): # Redirect internal matplotlib call to native function from ..axes import PlotAxes @@ -299,7 +299,7 @@ def _redirect_or_preprocess(self, *args, **kwargs): # Call main function return func(self, *args, **kwargs) # call unbound method - return _redirect_or_preprocess + return _preprocess_or_redirect return _decorator @@ -542,7 +542,7 @@ def _meta_coords(*args, which='x', **kwargs): # depend on other plotted content. # NOTE: Why IndexFormatter and not FixedFormatter? The former ensures labels # correspond to indices while the latter can mysteriously truncate labels. - from ..constructor import Locator, Formatter + from ..constructor import Formatter, Locator res = [] for data in args: data = _to_duck_array(data)