Skip to content

Commit

Permalink
Rename documented wrapper funcs '_wrapper' --> '_extras
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Jul 7, 2021
1 parent 48f2cf3 commit d1e1e85
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 133 deletions.
18 changes: 9 additions & 9 deletions docs/1dplots.py
Expand Up @@ -279,7 +279,7 @@
# ------------------------
#
# The `~matplotlib.axes.Axes.bar` and `~matplotlib.axes.Axes.barh` methods
# are wrapped by `~proplot.axes.bar_wrapper`,
# are wrapped by `~proplot.axes.bar_extras`,
# `~proplot.axes.apply_cycle`, and `~proplot.axes.standardize_1d`.
# You can now *group* or *stack* columns of data by passing 2D arrays to
# `~matplotlib.axes.Axes.bar` or `~matplotlib.axes.Axes.barh`, just like in
Expand All @@ -292,8 +292,8 @@
# `~proplot.axes.Axes.areax` methods. These are alises for
# `~matplotlib.axes.Axes.fill_between` and
# `~matplotlib.axes.Axes.fill_betweenx`, which are wrapped by
# `~proplot.axes.fill_between_wrapper` and
# `~proplot.axes.fill_betweenx_wrapper`. You can now *stack* or *overlay*
# `~proplot.axes.fill_between_extras` and
# `~proplot.axes.fill_betweenx_extras`. You can now *stack* or *overlay*
# columns of data by passing 2D arrays to `~proplot.axes.Axes.area` and
# `~proplot.axes.Axes.areax`, just like in `pandas`_. You can also now draw
# area plots that change color when the fill boundaries cross each other by
Expand Down Expand Up @@ -400,8 +400,8 @@
# --------------------------
#
# The `~matplotlib.axes.Axes.boxplot` and `~matplotlib.axes.Axes.violinplot`
# methods are now wrapped with `~proplot.axes.boxplot_wrapper`,
# `~proplot.axes.violinplot_wrapper`, `~proplot.axes.apply_cycle`,
# methods are now wrapped with `~proplot.axes.boxplot_extras`,
# `~proplot.axes.violinplot_extras`, `~proplot.axes.apply_cycle`,
# and `~proplot.axes.standardize_1d`. These wrappers add some useful
# options and apply aesthetically pleasing default settings. They also
# automatically apply axis labels based on the `~pandas.DataFrame` column
Expand Down Expand Up @@ -513,7 +513,7 @@
# ----------------------
#
# The `~matplotlib.axes.Axes.scatter` method is now wrapped by
# `~proplot.axes.scatter_wrapper`, `~proplot.axes.apply_cycle`, and
# `~proplot.axes.scatter_extras`, `~proplot.axes.apply_cycle`, and
# `~proplot.axes.standardize_1d`. This means that
# `~matplotlib.axes.Axes.scatter` now accepts 2D arrays, just like
# `~matplotlib.axes.Axes.plot`. Also, successive calls to
Expand All @@ -525,7 +525,7 @@
#
# ProPlot also supports property cycling for `~proplot.axes.Axes.step` plots
# and wraps the `~matplotlib.axes.Axes.vlines` and `~matplotlib.axes.Axes.hlines`
# methods with `~proplot.axes.vlines_wrapper` and `~proplot.axes.hlines_wrapper`,
# methods with `~proplot.axes.vlines_extras` and `~proplot.axes.hlines_extras`,
# which adds the ability to use different colors for "negative" and "positive" lines.

# %%
Expand All @@ -545,15 +545,15 @@

# Scatter plot with property cycler
ax = axs[0]
ax.format(title='Extra prop cycle properties')
ax.format(title='With property cycle')
obj = ax.scatter(
x, data, legend='ul', cycle='Set2', legend_kw={'ncols': 2},
cycle_kw={'marker': ['x', 'o', 'x', 'o'], 'markersize': [5, 10, 20, 30]}
)

# Scatter plot with colormap
ax = axs[1]
ax.format(title='Scatter plot with cmap')
ax.format(title='With colormap')
data = state.rand(2, 100)
obj = ax.scatter(
*data, color=data.sum(axis=0), size=state.rand(100), smin=3, smax=30,
Expand Down
4 changes: 2 additions & 2 deletions docs/colorbars_legends.py
Expand Up @@ -194,7 +194,7 @@
# ---------------------
#
# The `proplot.figure.Figure.colorbar` and `proplot.axes.Axes.colorbar`
# methods are wrapped by `~proplot.axes.colorbar_wrapper`, which adds several
# methods are wrapped by `~proplot.axes.colorbar_extras`, which adds several
# new features.
#
# You can now draw colorbars from *lists of colors* or *lists of artists* by
Expand Down Expand Up @@ -253,7 +253,7 @@
# -------------------
#
# The `proplot.figure.Figure.legend` and `proplot.axes.Axes.legend` methods
# are wrapped by `~proplot.axes.legend_wrapper`, which adds several new features.
# are wrapped by `~proplot.axes.legend_extras`, which adds several new features.
#
# You can draw legends with centered legend rows, either by passing
# ``center=True`` or by passing list of lists of plot handles. This is
Expand Down
2 changes: 1 addition & 1 deletion docs/subplots.py
Expand Up @@ -333,7 +333,7 @@
# out against plotted content. These simple "borders" and "boxes"
# can also be used by passing ``border=True`` or ``bbox=True`` to
# `~matplotlib.axes.Axes.text`, which ProPlot wraps with
# `~proplot.axes.plot.text_wrapper`. See the :ref:`plotting sections <ug_1dplots>`
# `~proplot.axes.text_extras`. See the :ref:`plotting sections <ug_1dplots>`
# for details on wrapper functions.

# %%
Expand Down
90 changes: 50 additions & 40 deletions proplot/axes/base.py
Expand Up @@ -24,26 +24,26 @@
from .plot import (
_apply_cmap,
_apply_cycle,
_bar_wrapper,
_barh_wrapper,
_boxplot_wrapper,
_fill_between_wrapper,
_fill_betweenx_wrapper,
_bar_extras,
_barh_extras,
_boxplot_extras,
_fill_between_extras,
_fill_betweenx_extras,
_get_transform,
_hist_wrapper,
_hlines_wrapper,
_hist_extras,
_hlines_extras,
_indicate_error,
_parametric_wrapper,
_plot_wrapper,
_scatter_wrapper,
_parametric_extras,
_plot_extras,
_scatter_extras,
_standardize_1d,
_standardize_2d,
_stem_wrapper,
_text_wrapper,
_violinplot_wrapper,
_vlines_wrapper,
colorbar_wrapper,
legend_wrapper,
_stem_extras,
_text_extras,
_violinplot_extras,
_vlines_extras,
colorbar_extras,
legend_extras,
)

__all__ = ['Axes']
Expand Down Expand Up @@ -1017,7 +1017,7 @@ def area(self, *args, **kwargs):
See also
--------
proplot.axes.plot.fill_between_wrapper
proplot.axes.fill_between_extras
"""
# NOTE: *Cannot* assign area = axes.Axes.fill_between because the
# wrapper won't be applied and for some reason it messes up
Expand All @@ -1030,7 +1030,7 @@ def areax(self, *args, **kwargs):
See also
--------
proplot.axes.plot.fill_betweenx_wrapper
proplot.axes.fill_betweenx_extras
"""
return self.fill_betweenx(*args, **kwargs)

Expand All @@ -1040,7 +1040,7 @@ def boxes(self, *args, **kwargs):
See also
--------
proplot.axes.plot.boxplot_wrapper
proplot.axes.boxplot_extras
"""
return self.boxplot(*args, **kwargs)

Expand Down Expand Up @@ -1270,7 +1270,7 @@ def panel_axes(self, side, **kwargs):
side = self._loc_translate(side, 'panel')
return self.figure._add_axes_panel(self, side, **kwargs)

@_parametric_wrapper
@_parametric_extras
@_standardize_1d
@_apply_cmap
def parametric(
Expand Down Expand Up @@ -1363,7 +1363,7 @@ def violins(self, *args, **kwargs):
See also
--------
proplot.axes.plot.violinplot_wrapper
proplot.axes.violinplot_extras
"""
return self.violinplot(*args, **kwargs)

Expand Down Expand Up @@ -1581,7 +1581,7 @@ def colorbar(
):
"""
Add an *inset* colorbar or *outer* colorbar along the outside edge of
the axes. See `~proplot.axes.colorbar_wrapper` for details.
the axes. See `~proplot.axes.colorbar_extras` for details.
Parameters
----------
Expand Down Expand Up @@ -1638,7 +1638,12 @@ def colorbar(
Other parameters
----------------
*args, **kwargs
Passed to `~proplot.axes.colorbar_wrapper`.
Passed to `~proplot.axes.colorbar_extras`.
See also
--------
proplot.figure.Figure.colorbar
proplot.axes.colorbar_extras
"""
# TODO: Add option to pad the frame away from the axes edge
# TODO: Get the 'best' inset colorbar location using the legend algorithm.
Expand Down Expand Up @@ -1666,7 +1671,7 @@ def colorbar(
ax, kwargs = self._inset_colorbar_axes(loc=loc, width=width, length=length, pad=pad, **kwargs) # noqa: E501

# Generate colorbar
obj = colorbar_wrapper(ax, mappable, values, **kwargs)
obj = colorbar_extras(ax, mappable, values, **kwargs)
self._add_colorbar_legend(loc, obj, legend=False) # possibly replace another
return obj

Expand All @@ -1676,7 +1681,7 @@ def legend(
):
"""
Add an *inset* legend or *outer* legend along the edge of the axes.
See `~proplot.axes.legend_wrapper` for details.
See `~proplot.axes.legend_extras` for details.
Parameters
----------
Expand Down Expand Up @@ -1725,7 +1730,12 @@ def legend(
Other parameters
----------------
*args, **kwargs
Passed to `~proplot.axes.legend_wrapper`.
Passed to `~proplot.axes.legend_extras`.
See also
--------
proplot.figure.Figure.legend
proplot.axes.legend_extras
"""
if loc != 'fill':
loc = self._loc_translate(loc, 'legend')
Expand Down Expand Up @@ -1767,7 +1777,7 @@ def legend(
raise ValueError(f'Invalid panel side {side!r}.')

# Generate legend
obj = legend_wrapper(self, handles, labels, loc=loc, **kwargs)
obj = legend_extras(self, handles, labels, loc=loc, **kwargs)
self._add_colorbar_legend(loc, obj, legend=True) # possibly replace another
return obj

Expand Down Expand Up @@ -1812,34 +1822,34 @@ def number(self, num):

# Wrapped by special functions
# Also support redirecting to Basemap methods
text = _text_wrapper(
text = _text_extras(
maxes.Axes.text
)
plot = _plot_wrapper(_standardize_1d(_indicate_error(_apply_cycle(
plot = _plot_extras(_standardize_1d(_indicate_error(_apply_cycle(
maxes.Axes.plot
))))
scatter = _scatter_wrapper(_standardize_1d(_indicate_error(_apply_cycle(
scatter = _scatter_extras(_standardize_1d(_indicate_error(_apply_cycle(
maxes.Axes.scatter
))))
bar = _bar_wrapper(_standardize_1d(_indicate_error(_apply_cycle(
bar = _bar_extras(_standardize_1d(_indicate_error(_apply_cycle(
maxes.Axes.bar
))))
barh = _barh_wrapper( # calls self.bar
barh = _barh_extras( # calls self.bar
maxes.Axes.barh
)
hist = _hist_wrapper(_standardize_1d(_apply_cycle(
hist = _hist_extras(_standardize_1d(_apply_cycle(
maxes.Axes.hist
)))
boxplot = _boxplot_wrapper(_standardize_1d(_apply_cycle(
boxplot = _boxplot_extras(_standardize_1d(_apply_cycle(
maxes.Axes.boxplot
)))
violinplot = _violinplot_wrapper(_standardize_1d(_indicate_error(_apply_cycle(
violinplot = _violinplot_extras(_standardize_1d(_indicate_error(_apply_cycle(
maxes.Axes.violinplot
))))
fill_between = _fill_between_wrapper(_standardize_1d(_apply_cycle(
fill_between = _fill_between_extras(_standardize_1d(_apply_cycle(
maxes.Axes.fill_between
)))
fill_betweenx = _fill_betweenx_wrapper(_standardize_1d(_apply_cycle(
fill_betweenx = _fill_betweenx_extras(_standardize_1d(_apply_cycle(
maxes.Axes.fill_betweenx
)))

Expand All @@ -1852,13 +1862,13 @@ def number(self, num):
))

# Wrapped by standardizer
stem = _standardize_1d(_stem_wrapper(
stem = _standardize_1d(_stem_extras(
maxes.Axes.stem
))
hlines = _standardize_1d(_hlines_wrapper(
hlines = _standardize_1d(_hlines_extras(
maxes.Axes.hlines
))
vlines = _standardize_1d(_vlines_wrapper(
vlines = _standardize_1d(_vlines_extras(
maxes.Axes.vlines
))

Expand Down
16 changes: 8 additions & 8 deletions proplot/axes/geo.py
Expand Up @@ -25,11 +25,11 @@
_default_latlon,
_default_transform,
_indicate_error,
_plot_wrapper,
_scatter_wrapper,
_plot_extras,
_scatter_extras,
_standardize_1d,
_standardize_2d,
_text_wrapper,
_text_extras,
)

try:
Expand Down Expand Up @@ -1187,14 +1187,14 @@ def projection(self, map_projection):
# TODO: Remove this duplication!
# NOTE: Do not wrap fill_between because it is broken in cartopy
if GeoAxesBase is not object:
text = _text_wrapper(
text = _text_extras(
GeoAxesBase.text
)
fill = _default_transform(GeoAxesBase.fill)
plot = _default_transform(_plot_wrapper(_standardize_1d(
plot = _default_transform(_plot_extras(_standardize_1d(
_indicate_error(_apply_cycle(GeoAxesBase.plot))
)))
scatter = _default_transform(_scatter_wrapper(_standardize_1d(
scatter = _default_transform(_scatter_extras(_standardize_1d(
_indicate_error(_apply_cycle(GeoAxesBase.scatter))
)))
contour = _default_transform(_standardize_2d(_apply_cmap(
Expand Down Expand Up @@ -1520,10 +1520,10 @@ def projection(self, map_projection):
self._map_projection = map_projection

# Wrapped methods
plot = _basemap_norecurse(_default_latlon(_plot_wrapper(_standardize_1d(
plot = _basemap_norecurse(_default_latlon(_plot_extras(_standardize_1d(
_indicate_error(_apply_cycle(_basemap_redirect(maxes.Axes.plot)))
))))
scatter = _basemap_norecurse(_default_latlon(_scatter_wrapper(_standardize_1d(
scatter = _basemap_norecurse(_default_latlon(_scatter_extras(_standardize_1d(
_indicate_error(_apply_cycle(_basemap_redirect(maxes.Axes.scatter)))
))))
contour = _basemap_norecurse(_default_latlon(_standardize_2d(_apply_cmap(
Expand Down

0 comments on commit d1e1e85

Please sign in to comment.