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

Skip to content

Commit 57b716e

Browse files
committed
revert explicit keyword arguments in Axes.stem
1 parent c6407b1 commit 57b716e

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,19 +2391,19 @@ def broken_barh(self, xranges, yrange, **kwargs):
23912391
return col
23922392

23932393
@_preprocess_data(replace_all_args=True, label_namer=None)
2394-
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2395-
label=None, **kwargs):
2394+
def stem(self, *args, **kwargs):
23962395
"""
23972396
Create a stem plot.
23982397
2399-
Call signatures::
2400-
2401-
stem(y)
2402-
stem(x, y)
2403-
24042398
A stem plot plots vertical lines at each *x* location from the baseline
24052399
to *y*, and places a marker there.
24062400
2401+
Call signature::
2402+
2403+
stem([x,] y, linefmt=None, markerfmt=None, basefmt=None)
2404+
2405+
The x-positions are optional. The formats may be provided either as
2406+
positional or as keyword-arguments.
24072407
24082408
Parameters
24092409
----------
@@ -2462,25 +2462,39 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
24622462
24632463
Returns
24642464
-------
2465-
a :class:`~matplotlib.container.StemContainer`
2465+
:class:`~matplotlib.container.StemContainer`
2466+
The stemcontainer may be treated like a tuple
2467+
(*markerline*, *stemlines*, *baseline*)
24662468
2467-
The stemcontainer may be treated like a tuple
2468-
(*markerline*, *stemlines*, *baseline*)
24692469
2470+
Notes
2471+
-----
24702472
24712473
.. seealso::
24722474
The MATLAB function
24732475
`stem <http://www.mathworks.com/help/techdoc/ref/stem.html>`_
24742476
which inspired this method.
24752477
24762478
"""
2479+
2480+
# kwargs handling
2481+
# We would like to have a signature with explicit kewords:
2482+
# stem(*args, linefmt=None, markerfmt=None, basefmt=None,
2483+
# bottom=0, label=None)
2484+
# Unfortunately, this is not supported in Python 2.x. There, *args
2485+
# can only exist after keyword arguments.
2486+
linefmt = kwargs.pop('linefmt', None)
2487+
markerfmt = kwargs.pop('markerfmt', None)
2488+
basefmt = kwargs.pop('basefmt', None)
2489+
bottom = kwargs.pop('bottom', None)
2490+
if bottom is None:
2491+
bottom = 0
2492+
label = kwargs.pop('label', None)
24772493
if kwargs:
2478-
# TODO: to remove the deprecated behavior, simply remove **kwargs
2479-
# from the function signature and remove this warning.
24802494
warn_deprecated(since='2.2',
2481-
message = "stem() got an unexpected keyword "
2482-
"argument '%s'. This will raise a "
2483-
"TypeError in future versions." % (
2495+
message="stem() got an unexpected keyword "
2496+
"argument '%s'. This will raise a "
2497+
"TypeError in future versions." % (
24842498
next(k for k in kwargs), )
24852499
)
24862500

@@ -2503,7 +2517,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25032517
second = np.arange(len(y))
25042518
x = second
25052519

2506-
# Popping some defaults
2520+
# defaults for formats
25072521
if linefmt is None:
25082522
try:
25092523
# fallback to positional argument
@@ -2550,9 +2564,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25502564
else:
25512565
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
25522566

2553-
if bottom is None:
2554-
bottom = 0
2555-
25562567
markerline, = self.plot(x, y, color=markercolor, linestyle=markerstyle,
25572568
marker=markermarker, label="_nolegend_")
25582569

lib/matplotlib/container.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ def get_children(self):
111111

112112
class BarContainer(Container):
113113
"""
114-
Container for the artists of bar plots.
115-
116-
E.g. created in a :meth:`.Axes.bar` plot.
114+
Container for the artists of bar plots (e.g. created by `.Axes.bar`).
117115
118116
The container can be treated as a tuple of the *patches* themselves.
119117
Additionally, you can access these and further parameters by the
@@ -138,9 +136,7 @@ def __init__(self, patches, errorbar=None, **kwargs):
138136

139137
class ErrorbarContainer(Container):
140138
"""
141-
Container for the artists of error bars.
142-
143-
E.g. created in a :meth:`.Axes.errorbar` plot.
139+
Container for the artists of error bars (e.g. created by `.Axes.errorbar`).
144140
145141
The container can be treated as the *lines* tuple itself.
146142
Additionally, you can access these and further parameters by the

0 commit comments

Comments
 (0)