Skip to content

Implement wrappers as decorators and document features on methods #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
464d41e
Import docstring
lukelbd Sep 17, 2019
c962d63
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Sep 17, 2019
e2f0777
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Sep 17, 2019
a89016c
Add _concatenate_axes_docstrings, make behavior dependent on whether …
lukelbd Sep 17, 2019
93c6405
Prepend matplotlib summary to proplot method docstrings
lukelbd Sep 17, 2019
7a5692b
Implement 1d wrappers and begin adding interp docstring segments
lukelbd Sep 17, 2019
cd43068
Standardize docstring fragment names, add new fragments
lukelbd Sep 29, 2019
1ff63cc
Fix ginormous merge conflict
lukelbd Nov 28, 2019
b9c9e6c
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Nov 30, 2019
a41df85
Pep8 compliance
lukelbd Nov 30, 2019
da9e82a
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Nov 30, 2019
fb37b47
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Dec 2, 2019
9ac7946
Merge from master
lukelbd Dec 2, 2019
ae389be
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Dec 2, 2019
27bae6f
Fix RST links
lukelbd Dec 2, 2019
ec6c359
Merge from master
lukelbd Dec 7, 2019
65d3142
Merge from master
lukelbd Dec 14, 2019
902f101
Fix example size
lukelbd Dec 14, 2019
63474ad
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Dec 14, 2019
499d7f2
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
7ff34f0
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
e1131f5
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
d9c2260
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
6c86d3c
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
fb9ba07
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 7, 2020
ca72203
Merge branch 'master' into wrapper-docs-on-methods
lukelbd Jan 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into wrapper-docs-on-methods
  • Loading branch information
lukelbd committed Jan 7, 2020
commit 499d7f2b1eaa4a6959df540625770ee9eb0ded3e
88 changes: 30 additions & 58 deletions proplot/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect
import functools
from matplotlib import docstring
from numbers import Integral
from numbers import Integral, Number
import matplotlib.projections as mproj
import matplotlib.axes as maxes
import matplotlib.dates as mdates
Expand Down Expand Up @@ -78,40 +78,6 @@
'uc': 'upper center',
'lc': 'lower center',
}
SIDE_TRANSLATE = {
'l': 'left',
'r': 'right',
'b': 'bottom',
't': 'top',
}
LOC_TRANSLATE = {
None: None,
'inset': 'best',
'i': 'best',
0: 'best',
1: 'upper right',
2: 'upper left',
3: 'lower left',
4: 'lower right',
5: 'center left',
6: 'center right',
7: 'lower center',
8: 'upper center',
9: 'center',
'l': 'left',
'r': 'right',
'b': 'bottom',
't': 'top',
'c': 'center',
'ur': 'upper right',
'ul': 'upper left',
'll': 'lower left',
'lr': 'lower right',
'cr': 'center right',
'cl': 'center left',
'uc': 'upper center',
'lc': 'lower center',
}


def _get_transform(self, transform):
Expand Down Expand Up @@ -1064,17 +1030,18 @@ def boxes(self, *args, **kwargs):
@_concatenate_docstrings
@docstring.dedent_interpd
def boxplot(
self, *args,
color='k', fill=True, fillcolor=None, fillalpha=0.7,
lw=None, linewidth=0.7, orientation=None,
marker=None, markersize=None,
boxcolor=None, boxlw=None,
capcolor=None, caplw=None,
meancolor=None, meanlw=None,
mediancolor=None, medianlw=None,
whiskercolor=None, whiskerlw=None,
fliercolor=None, flierlw=None,
**kwargs):
self, *args,
color='k', fill=True, fillcolor=None, fillalpha=0.7,
lw=None, linewidth=0.7, orientation=None,
marker=None, markersize=None,
boxcolor=None, boxlw=None,
capcolor=None, caplw=None,
meancolor=None, meanlw=None,
mediancolor=None, medianlw=None,
whiskercolor=None, whiskerlw=None,
fliercolor=None, flierlw=None,
**kwargs
):
"""
Adds convenient keyword args. Fills the objects with a cycle color
by default.
Expand Down Expand Up @@ -1170,10 +1137,12 @@ def boxplot(
return obj

@docstring.dedent_interpd
def colorbar(self, *args, loc=None, pad=None,
length=None, width=None, space=None, frame=None, frameon=None,
alpha=None, linewidth=None, edgecolor=None, facecolor=None,
**kwargs):
def colorbar(
self, *args, loc=None, pad=None,
length=None, width=None, space=None, frame=None, frameon=None,
alpha=None, linewidth=None, edgecolor=None, facecolor=None,
**kwargs
):
"""
Adds colorbar as an *inset* or along the outside edge of the axes.

Expand Down Expand Up @@ -1547,8 +1516,10 @@ def hist(self, x, bins=None, **kwargs):
))
return hist(self, x, bins=bins, **kwargs)

def inset_axes(self, bounds, *, transform=None, zorder=5,
zoom=True, zoom_kw=None, **kwargs):
def inset_axes(
self, bounds, *, transform=None, zorder=5,
zoom=True, zoom_kw=None, **kwargs
):
"""
Like the builtin `~matplotlib.axes.Axes.inset_axes` method, but
draws an inset `XYAxes` axes and adds some options.
Expand Down Expand Up @@ -3706,7 +3677,8 @@ def format(
`~mpl_toolkits.basemap.Basemap.drawmeridians` and
`~mpl_toolkits.basemap.Basemap.drawparallels` methods.

land, ocean, coast, rivers, lakes, borders, innerborders : bool, optional
land, ocean, coast, rivers, lakes, borders, innerborders : bool, \
optional
Toggles various geographic features. These are actually the
:rcraw:`land`, :rcraw:`ocean`, :rcraw:`coast`, :rcraw:`rivers`,
:rcraw:`lakes`, :rcraw:`borders`, and :rcraw:`innerborders`
Expand All @@ -3729,11 +3701,11 @@ def format(
See also
--------
:py:obj:`Axes.format`, :py:obj:`Axes.context`
""" # noqa
# Parse alternative keyword args
# TODO: Why isn't default latmax 80 respected sometimes?
context, kwargs = self.context(**kwargs)
with context:
"""
rc_kw, rc_mode, kwargs = _parse_format(**kwargs)
with rc.context(rc_kw, mode=rc_mode):
# Parse alternative keyword args
# TODO: Why isn't default latmax 80 respected sometimes?
lonlines = _notNone(
lonlines, lonlocator, rc.get('geogrid.lonstep', context=True),
names=('lonlines', 'lonlocator')
Expand Down
33 changes: 17 additions & 16 deletions proplot/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,22 +1898,23 @@ def _axes_dict(naxs, value, kw=False, default=None):

@docstring.dedent_interpd
def subplots(
array=None, ncols=1, nrows=1,
ref=1, order='C',
aspect=1, figsize=None,
width=None, height=None, axwidth=None, axheight=None, journal=None,
hspace=None, wspace=None, space=None,
hratios=None, wratios=None,
width_ratios=None, height_ratios=None,
flush=None, wflush=None, hflush=None,
left=None, bottom=None, right=None, top=None,
tight=None, pad=None, axpad=None, panelpad=None,
span=None, spanx=None, spany=None,
align=None, alignx=None, aligny=None,
share=None, sharex=None, sharey=None,
basemap=False, proj=None, projection=None,
proj_kw=None, projection_kw=None,
autoformat=True, includepanels=False):
array=None, ncols=1, nrows=1,
ref=1, order='C',
aspect=1, figsize=None,
width=None, height=None, journal=None,
axwidth=None, axheight=None,
hspace=None, wspace=None, space=None,
hratios=None, wratios=None,
width_ratios=None, height_ratios=None,
flush=None, wflush=None, hflush=None,
left=None, bottom=None, right=None, top=None,
span=None, spanx=None, spany=None,
align=None, alignx=None, aligny=None,
share=None, sharex=None, sharey=None,
basemap=False, proj=None, projection=None,
proj_kw=None, projection_kw=None,
**kwargs
):
"""
Analogous to `matplotlib.pyplot.subplots`, creates a figure with a single
axes or arbitrary grids of axes, any of which can be map projections.
Expand Down
43 changes: 22 additions & 21 deletions proplot/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,17 +695,17 @@ def _errorbar_values(data, idata, bardata=None, barrange=None, barstd=False):


def add_errorbars(
self, func, *args,
medians=False, means=False,
boxes=None, bars=None,
boxdata=None, bardata=None,
boxstd=False, barstd=False,
boxmarker=True, boxmarkercolor='white',
boxrange=(25, 75), barrange=(5, 95), boxcolor=None, barcolor=None,
boxlw=None, barlw=None, capsize=None,
boxzorder=3, barzorder=3,
**kwargs):
# Function
self, func, *args,
medians=False, means=False,
boxes=None, bars=None,
boxdata=None, bardata=None,
boxstd=False, barstd=False,
boxmarker=True, boxmarkercolor='white',
boxrange=(25, 75), barrange=(5, 95), boxcolor=None, barcolor=None,
boxlw=None, barlw=None, capsize=None,
boxzorder=3, barzorder=3,
**kwargs
):
name = func.__name__
x, y, *args = args
# Sensible defaults
Expand Down Expand Up @@ -1122,16 +1122,17 @@ def cycle_changer(self, func, *args,


def cmap_changer(
self, func, *args, cmap=None, cmap_kw=None,
extend='neither', norm=None, norm_kw=None,
N=None, levels=None, values=None, centers=None, vmin=None, vmax=None,
locator=None, symmetric=False, locator_kw=None,
edgefix=None, labels=False, labels_kw=None, fmt=None, precision=2,
colorbar=False, colorbar_kw=None, panel_kw=None,
lw=None, linewidth=None, linewidths=None,
ls=None, linestyle=None, linestyles=None,
color=None, colors=None, edgecolor=None, edgecolors=None,
**kwargs):
self, func, *args, cmap=None, cmap_kw=None,
extend='neither', norm=None, norm_kw=None,
N=None, levels=None, values=None, centers=None, vmin=None, vmax=None,
locator=None, symmetric=False, locator_kw=None,
edgefix=None, labels=False, labels_kw=None, fmt=None, precision=2,
colorbar=False, colorbar_kw=None, panel_kw=None,
lw=None, linewidth=None, linewidths=None,
ls=None, linestyle=None, linestyles=None,
color=None, colors=None, edgecolor=None, edgecolors=None,
**kwargs
):
# Wraps methods that take a ``cmap`` argument (%(methods)s),
# adds several new keyword args and features.
# Uses the `~proplot.styletools.BinNorm` normalizer to bin data into
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.