Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c86d3c

Browse files
committed
Merge branch 'master' into wrapper-docs-on-methods
2 parents d9c2260 + 71e821e commit 6c86d3c

File tree

10 files changed

+332
-325
lines changed

10 files changed

+332
-325
lines changed

‎docs/2dplots.ipynb‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@
7171
"\n",
7272
"# DataFrame\n",
7373
"data = state.rand(20, 20)\n",
74-
"df = pd.DataFrame(data.cumsum(axis=0).cumsum(\n",
75-
" axis=1), index=[*'JFMAMJJASONDJFMAMJJA'])\n",
74+
"df = pd.DataFrame(\n",
75+
" data.cumsum(axis=0).cumsum(axis=1),\n",
76+
" index=[*'JFMAMJJASONDJFMAMJJA']\n",
77+
")\n",
7678
"df.name = 'temporal data'\n",
7779
"df.index.name = 'index'\n",
7880
"df.columns.name = 'time (days)'"
@@ -257,8 +259,10 @@
257259
"import proplot as plot\n",
258260
"import pandas as pd\n",
259261
"import numpy as np\n",
260-
"f, axs = plot.subplots([[1, 1, 2, 2], [0, 3, 3, 0]],\n",
261-
" axwidth=2, share=1, span=False, hratios=(1, 0.9))\n",
262+
"f, axs = plot.subplots(\n",
263+
" [[1, 1, 2, 2], [0, 3, 3, 0]],\n",
264+
" axwidth=2, share=1, span=False, hratios=(1, 0.9)\n",
265+
")\n",
262266
"state = np.random.RandomState(51423)\n",
263267
"data = state.rand(6, 6)\n",
264268
"data = pd.DataFrame(data, index=pd.Index(['a', 'b', 'c', 'd', 'e', 'f']))\n",

‎proplot/__init__.py‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@
3232
if not _os.path.isdir(_rc_sub):
3333
_os.mkdir(_rc_sub)
3434

35-
# Initialize customization file
36-
_rc_file = _os.path.join(_os.path.expanduser('~'), '.proplotrc')
37-
_rc_file_default = _os.path.join(_os.path.dirname(__file__), '.proplotrc')
38-
if not _os.path.isfile(_rc_file):
39-
with open(_rc_file_default) as f:
40-
lines = ''.join(
41-
'# ' + line if line.strip() and line[0] != '#' else line
42-
for line in f.readlines()
43-
)
44-
with open(_rc_file, 'x') as f:
45-
f.write(
46-
'# User default settings\n'
47-
'# See https://proplot.readthedocs.io/en/latest/rctools.html\n'
48-
+ lines
49-
)
50-
5135
# SCM versioning
5236
name = 'proplot'
5337
try:

‎proplot/axes.py‎

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ def _abc(i):
159159

160160

161161
def _disable_decorator(msg):
162-
"""
163-
Generate decorators that disable methods. Also sets __doc__ to None so
164-
that ProPlot fork of automodapi doesn't add these methods to the website
165-
documentation. Users can still call help(ax.method) because python looks
166-
for superclass method docstrings if a docstring is empty.
167-
"""
162+
"""Return a decorator that disables methods with message `msg`. The
163+
docstring is set to ``None`` so the ProPlot fork of automodapi doesn't add
164+
these methods to the website documentation. Users can still call
165+
help(ax.method) because python looks for superclass method docstrings if a
166+
docstring is empty."""
168167
def decorator(func):
169168
@functools.wraps(func)
170169
def _wrapper(self, *args, **kwargs):
@@ -269,7 +268,7 @@ def _draw_auto_legends_colorbars(self):
269268
self._auto_colorbar = {}
270269

271270
def _get_side_axes(self, side):
272-
"""Returns axes whose left, right, top, or bottom side abutts
271+
"""Return the axes whose left, right, top, or bottom sides abutt
273272
against the same row or column as this axes."""
274273
s = side[0]
275274
if s not in 'lrbt':
@@ -287,10 +286,9 @@ def _get_side_axes(self, side):
287286
return axs
288287

289288
def _get_extent_axes(self, x):
290-
"""Returns axes whose horizontal or vertical extent in the main
289+
"""Return the axes whose horizontal or vertical extent in the main
291290
gridspec matches the horizontal or vertical extend of this axes.
292-
Also sorts the list so the leftmost or bottommost axes is at the
293-
start of the list."""
291+
The lefmost or bottommost axes are at the start of the list."""
294292
if not hasattr(self, 'get_subplotspec'):
295293
return [self]
296294
y = ('y' if x == 'x' else 'x')
@@ -447,8 +445,9 @@ def _range_tightbbox(self, x):
447445
return bbox.ymin, bbox.ymax
448446

449447
def _reassign_suplabel(self, side):
450-
"""Re-assigns the column and row labels to panel axes, if they exist.
451-
This is called by `~proplot.subplots.Figure._align_suplabel`."""
448+
"""Re-assign the column and row labels to the relevant panel if
449+
present. This is called by `~proplot.subplots.Figure._align_suplabel`.
450+
"""
452451
# Place column and row labels on panels instead of axes -- works when
453452
# this is called on the main axes *or* on the relevant panel itself
454453
# TODO: Mixed figure panels with super labels? How does that work?
@@ -476,9 +475,10 @@ def _reassign_suplabel(self, side):
476475
return pax
477476

478477
def _reassign_title(self):
479-
"""Re-assigns title to the first upper panel if present. We cannot
480-
simply add upper panel as child axes, because then title will be offset
481-
but still belong to main axes, which messes up tight bounding box."""
478+
"""Re-assign the title to the first upper panel if present. We cannot
479+
simply add the upper panel as a child axes, because then the title will
480+
be offset but still belong to main axes, which messes up the tight
481+
bounding box."""
482482
# Reassign title from main axes to top panel -- works when this is
483483
# called on the main axes *or* on the top panel itself. This is
484484
# critical for bounding box calcs; not always clear whether draw() and
@@ -656,7 +656,8 @@ def _update_axislabels(self, x='x', **kwargs):
656656
getattr(pax, x + 'axis').label.update(kwargs)
657657

658658
def _update_title(self, obj, **kwargs):
659-
"""Redraws title if updating with input keyword args failed."""
659+
"""Redraw the title if updating with the input keyword arguments
660+
failed."""
660661
# Try to just return updated object, redraw may be necessary
661662
# WARNING: Making text instances invisible seems to mess up tight
662663
# bounding box calculations and cause other issues. Just reset text.
@@ -1452,25 +1453,27 @@ def fill_betweenx(self, *args, **kwargs):
14521453
return self._fill_between_apply(*args, betweenx=True, **kwargs)
14531454

14541455
def get_size_inches(self):
1455-
"""Returns the width and the height of the axes in inches."""
1456+
"""Return the width and the height of the axes in inches. Similar
1457+
to `~matplotlib.Figure.get_size_inches`."""
14561458
width, height = self.figure.get_size_inches()
14571459
bbox = self.get_position()
14581460
width = width * abs(bbox.width)
14591461
height = height * abs(bbox.height)
14601462
return width, height
14611463

14621464
def get_tightbbox(self, renderer, *args, **kwargs):
1463-
"""Adds post-processing steps before tight bounding box is
1464-
calculated, and stores the bounding box as an attribute."""
1465+
"""Perform post-processing steps, return the tight bounding box
1466+
surrounding axes artists, and cache the bounding box as an attribute.
1467+
"""
14651468
self._reassign_title()
14661469
bbox = super().get_tightbbox(renderer, *args, **kwargs)
14671470
self._tightbbox = bbox
14681471
return bbox
14691472

14701473
def heatmap(self, *args, **kwargs):
1471-
"""Calls `~matplotlib.axes.Axes.pcolormesh` and applies default formatting
1472-
that is suitable for heatmaps: no gridlines, no minor ticks, and major
1473-
ticks at the center of each grid box."""
1474+
"""Pass all arguments to `~matplotlib.axes.Axes.pcolormesh` then apply
1475+
settings that are suitable for heatmaps: no gridlines, no minor ticks,
1476+
and major ticks at the center of each grid box."""
14741477
obj = self.pcolormesh(*args, **kwargs)
14751478
xlocator, ylocator = None, None
14761479
if hasattr(obj, '_coordinates'):
@@ -1507,8 +1510,8 @@ def inset_axes(
15071510
zoom=True, zoom_kw=None, **kwargs
15081511
):
15091512
"""
1510-
Like the builtin `~matplotlib.axes.Axes.inset_axes` method, but
1511-
draws an inset `XYAxes` axes and adds some options.
1513+
Return an inset `CartesianAxes`. This is similar to the builtin
1514+
`~matplotlib.axes.Axes.inset_axes` but includes some extra options.
15121515
15131516
Parameters
15141517
----------
@@ -1568,11 +1571,11 @@ def indicate_inset_zoom(
15681571
color=None, edgecolor=None, **kwargs
15691572
):
15701573
"""
1571-
Called automatically when using `~Axes.inset` with ``zoom=True``.
1572-
Like `~matplotlib.axes.Axes.indicate_inset_zoom`, but *refreshes* the
1573-
lines at draw-time.
1574-
1575-
This method is called from the *inset* axes, not the parent axes.
1574+
Draw lines indicating the zoom range of the inset axes. This is similar
1575+
to the builtin `~matplotlib.axes.Axes.indicate_inset_zoom` except
1576+
lines are *refreshed* at draw-time. This is also called automatically
1577+
when ``zoom=True`` is passed to `~Axes.inset_axes`. Note this method
1578+
must be called from the *inset* axes and not the parent axes.
15761579
15771580
Parameters
15781581
----------
@@ -1721,7 +1724,7 @@ def legend(self, *args, loc=None, width=None, space=None, **kwargs):
17211724

17221725
def panel_axes(self, side, **kwargs):
17231726
"""
1724-
Returns a panel drawn along the edge of an axes.
1727+
Return a panel axes drawn along the edge of this axes.
17251728
17261729
Parameters
17271730
----------
@@ -2448,7 +2451,7 @@ def _alty_overrides(self):
24482451
self.patch.set_visible(False)
24492452

24502453
def _datex_rotate(self):
2451-
"""Applies default rotation to datetime axis coordinates."""
2454+
"""Apply default rotation to datetime axis coordinates."""
24522455
# NOTE: Rotation is done *before* horizontal/vertical alignment,
24532456
# cannot change alignment with set_tick_params. Must apply to text
24542457
# objects. fig.autofmt_date calls subplots_adjust, so cannot use it.
@@ -2464,7 +2467,7 @@ def _datex_rotate(self):
24642467
self._datex_rotated = True # do not need to apply more than once
24652468

24662469
def _dualx_overrides(self):
2467-
"""Lock child "dual" *x* axis limits to the parent."""
2470+
"""Lock the child "dual" *x* axis limits to the parent."""
24682471
# NOTE: We set the scale using private API to bypass application of
24692472
# set_default_locators_and_formatters: only_if_default=True is critical
24702473
# to prevent overriding user settings! We also bypass autoscale_view
@@ -2492,7 +2495,7 @@ def _dualx_overrides(self):
24922495
self._dualx_cache = (scale, *olim)
24932496

24942497
def _dualy_overrides(self):
2495-
"""Lock child "dual" *y* axis limits to the parent."""
2498+
"""Lock the child "dual" *y* axis limits to the parent."""
24962499
arg = self._dualy_arg
24972500
if arg is None:
24982501
return
@@ -2515,9 +2518,9 @@ def _dualy_overrides(self):
25152518
self._dualy_cache = (scale, *olim)
25162519

25172520
def _hide_labels(self):
2518-
"""Function called at drawtime that enforces "shared" axis and
2519-
tick labels. If this is not called at drawtime, "shared" labels can
2520-
be inadvertantly turned off e.g. when the axis scale is changed."""
2521+
"""Enforce the "shared" axis labels and axis tick labels. If this is
2522+
not called at drawtime, "shared" labels can be inadvertantly turned
2523+
off e.g. when the axis scale is changed."""
25212524
for x in 'xy':
25222525
# "Shared" axis and tick labels
25232526
axis = getattr(self, x + 'axis')
@@ -2859,10 +2862,12 @@ def format(
28592862
# NOTE: Allow tick labels to be present without ticks! User may
28602863
# want this sometimes! Same goes for spines!
28612864
xspineloc = _notNone(
2862-
xloc, xspineloc, None, names=('xloc', 'xspineloc')
2865+
xloc, xspineloc, None,
2866+
names=('xloc', 'xspineloc')
28632867
)
28642868
yspineloc = _notNone(
2865-
yloc, yspineloc, None, names=('yloc', 'yspineloc')
2869+
yloc, yspineloc, None,
2870+
names=('yloc', 'yspineloc')
28662871
)
28672872
xtickloc = _notNone(
28682873
xtickloc, xspineloc, _parse_rcloc('x', 'xtick')
@@ -3299,7 +3304,7 @@ def dualy(self, arg, **kwargs):
32993304
return ax
33003305

33013306
def draw(self, renderer=None, *args, **kwargs):
3302-
"""Adds post-processing steps before axes is drawn."""
3307+
"""Perform post-processing steps then draw the axes."""
33033308
# NOTE: This mimics matplotlib API, which calls identical
33043309
# post-processing steps in both draw() and get_tightbbox()
33053310
self._hide_labels()
@@ -3313,8 +3318,7 @@ def draw(self, renderer=None, *args, **kwargs):
33133318
super().draw(renderer, *args, **kwargs)
33143319

33153320
def get_tightbbox(self, renderer, *args, **kwargs):
3316-
"""Adds post-processing steps before tight bounding box is
3317-
calculated."""
3321+
"""Perform post-processing steps then return the tight bounding box."""
33183322
self._hide_labels()
33193323
self._altx_overrides()
33203324
self._alty_overrides()
@@ -4167,8 +4171,7 @@ def _hide_labels(self):
41674171
pass
41684172

41694173
def get_tightbbox(self, renderer, *args, **kwargs):
4170-
"""Draw gridliner objects so tight bounding box algorithm will
4171-
incorporate gridliner labels."""
4174+
"""Draw the gridliner objects then return the tight bounding box."""
41724175
self._hide_labels()
41734176
if self.get_autoscale_on() and self.ignore_existing_data_limits:
41744177
self.autoscale_view()
@@ -4235,8 +4238,6 @@ def projection(self, map_projection):
42354238
barbs = _default_transform(_standardize_2d(_cmap_changer(
42364239
GeoAxes.barbs
42374240
)))
4238-
4239-
# Wrapped only by cmap wrapper
42404241
tripcolor = _default_transform(_cmap_changer(
42414242
GeoAxes.tripcolor
42424243
))

0 commit comments

Comments
 (0)