Skip to content

Commit 5cb839f

Browse files
committed
Add 'location' as 'loc' alternative for legend/colorbar
1 parent 4385577 commit 5cb839f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

proplot/axes/base.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,14 +2173,17 @@ def _draw_colorbar(
21732173

21742174
@docstring.obfuscate_signature
21752175
@docstring.add_snippets
2176-
def colorbar(self, mappable, values=None, *, loc=None, queue=False, **kwargs):
2176+
def colorbar(
2177+
self, mappable, values=None, *, loc=None, location=None, queue=False,
2178+
**kwargs
2179+
):
21772180
"""
21782181
Add an inset colorbar or an outer colorbar along the edge of the axes.
21792182
21802183
Parameters
21812184
----------
21822185
%(axes.colorbar_args)s
2183-
loc : str, optional
2186+
loc, location : str, optional
21842187
The colorbar location. Default is :rc:`colorbar.loc`. Valid location
21852188
keys are shown in the below table.
21862189
@@ -2228,6 +2231,7 @@ def colorbar(self, mappable, values=None, *, loc=None, queue=False, **kwargs):
22282231
# Either draw right now or queue up for later
22292232
# The queue option lets us successively append objects (e.g. line handles)
22302233
# to a list later used for colorbar levels. Same as legend.
2234+
loc = _not_none(loc=loc, location=location)
22312235
loc = _translate_loc(loc, 'colorbar', default=rc['colorbar.loc'])
22322236
if queue:
22332237
obj = (mappable, values)
@@ -2663,14 +2667,17 @@ def _draw_legend(
26632667

26642668
@docstring.concatenate_original
26652669
@docstring.add_snippets
2666-
def legend(self, handles=None, labels=None, *, loc=None, queue=False, **kwargs):
2670+
def legend(
2671+
self, handles=None, labels=None, *, loc=None, location=None, queue=False,
2672+
**kwargs
2673+
):
26672674
"""
26682675
Add an *inset* legend or *outer* legend along the edge of the axes.
26692676
26702677
Parameters
26712678
----------
26722679
%(axes.legend_args)s
2673-
loc : int or str, optional
2680+
loc, location : int or str, optional
26742681
The legend location. Default is :rc:`legend.loc`. Valid location
26752682
keys are shown in the below table.
26762683
@@ -2714,6 +2721,7 @@ def legend(self, handles=None, labels=None, *, loc=None, queue=False, **kwargs):
27142721
# Either draw right now or queue up for later
27152722
# Handles can be successively added to a single location this way. This
27162723
# is used internally for on-the-fly legends.
2724+
loc = _not_none(loc=loc, location=location)
27172725
loc = _translate_loc(loc, 'legend', default=rc['legend.loc'])
27182726
if queue:
27192727
obj = (handles, labels)

proplot/figure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ def format(
14591459
@docstring.concatenate_original
14601460
@docstring.add_snippets
14611461
def colorbar(
1462-
self, mappable, values=None, *, loc='r',
1462+
self, mappable, values=None, *, loc=None, location=None,
14631463
row=None, col=None, rows=None, cols=None, span=None,
14641464
space=None, pad=None, width=None, **kwargs
14651465
):
@@ -1500,13 +1500,14 @@ def colorbar(
15001500
return ax.colorbar(mappable, values, space=space, pad=pad, width=width, **kwargs) # noqa: E501
15011501
# Figure panel colorbar
15021502
else:
1503+
loc = _not_none(loc=loc, location=location, default='r')
15031504
ax = self._add_figure_panel(loc, row=row, col=col, rows=rows, cols=cols, span=span, space=space, pad=pad, width=width) # noqa: E501
15041505
return ax.colorbar(mappable, values, loc='fill', **kwargs)
15051506

15061507
@docstring.concatenate_original
15071508
@docstring.add_snippets
15081509
def legend(
1509-
self, handles=None, labels=None, *, loc='r',
1510+
self, handles=None, labels=None, *, loc=None, location=None,
15101511
row=None, col=None, rows=None, cols=None, span=None,
15111512
space=None, pad=None, width=None, **kwargs
15121513
):
@@ -1539,6 +1540,7 @@ def legend(
15391540
return ax.legend(handles, labels, space=space, pad=pad, width=width, **kwargs) # noqa: E501
15401541
# Figure panel legend
15411542
else:
1543+
loc = _not_none(loc=loc, location=location, default='r')
15421544
ax = self._add_figure_panel(loc, row=row, col=col, rows=rows, cols=cols, span=span, space=space, pad=pad, width=width) # noqa: E501
15431545
return ax.legend(handles, labels, loc='fill', **kwargs)
15441546

0 commit comments

Comments
 (0)