Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a79026b

Browse filesBrowse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #23887: Add missing label argument to barh docs
1 parent 40e04aa commit a79026b
Copy full SHA for a79026b

File tree

Expand file treeCollapse file tree

2 files changed

+35
-20
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+35
-20
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+30-18Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
22282228
The width(s) of the bars.
22292229
22302230
bottom : float or array-like, default: 0
2231-
The y coordinate(s) of the bars bases.
2231+
The y coordinate(s) of the bottom side(s) of the bars.
22322232
22332233
align : {'center', 'edge'}, default: 'center'
22342234
Alignment of the bars to the *x* coordinates:
@@ -2278,8 +2278,8 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
22782278
errors.
22792279
- *None*: No errorbar. (Default)
22802280
2281-
See :doc:`/gallery/statistics/errorbar_features`
2282-
for an example on the usage of ``xerr`` and ``yerr``.
2281+
See :doc:`/gallery/statistics/errorbar_features` for an example on
2282+
the usage of *xerr* and *yerr*.
22832283
22842284
ecolor : color or list of color, default: 'black'
22852285
The line color of the errorbars.
@@ -2288,9 +2288,9 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
22882288
The length of the error bar caps in points.
22892289
22902290
error_kw : dict, optional
2291-
Dictionary of kwargs to be passed to the `~.Axes.errorbar`
2292-
method. Values of *ecolor* or *capsize* defined here take
2293-
precedence over the independent kwargs.
2291+
Dictionary of keyword arguments to be passed to the
2292+
`~.Axes.errorbar` method. Values of *ecolor* or *capsize* defined
2293+
here take precedence over the independent keyword arguments.
22942294
22952295
log : bool, default: False
22962296
If *True*, set the y-axis to be log scale.
@@ -2498,9 +2498,10 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
24982498

24992499
return bar_container
25002500

2501+
# @_preprocess_data() # let 'bar' do the unpacking..
25012502
@_docstring.dedent_interpd
25022503
def barh(self, y, width, height=0.8, left=None, *, align="center",
2503-
**kwargs):
2504+
data=None, **kwargs):
25042505
r"""
25052506
Make a horizontal bar plot.
25062507
@@ -2524,7 +2525,7 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
25242525
The heights of the bars.
25252526
25262527
left : float or array-like, default: 0
2527-
The x coordinates of the left sides of the bars.
2528+
The x coordinates of the left side(s) of the bars.
25282529
25292530
align : {'center', 'edge'}, default: 'center'
25302531
Alignment of the base to the *y* coordinates*:
@@ -2556,9 +2557,17 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
25562557
The tick labels of the bars.
25572558
Default: None (Use default numeric labels.)
25582559
2560+
label : str or list of str, optional
2561+
A single label is attached to the resulting `.BarContainer` as a
2562+
label for the whole dataset.
2563+
If a list is provided, it must be the same length as *y* and
2564+
labels the individual bars. Repeated labels are not de-duplicated
2565+
and will cause repeated label entries, so this is best used when
2566+
bars also differ in style (e.g., by passing a list to *color*.)
2567+
25592568
xerr, yerr : float or array-like of shape(N,) or shape(2, N), optional
2560-
If not ``None``, add horizontal / vertical errorbars to the
2561-
bar tips. The values are +/- sizes relative to the data:
2569+
If not *None*, add horizontal / vertical errorbars to the bar tips.
2570+
The values are +/- sizes relative to the data:
25622571
25632572
- scalar: symmetric +/- values for all bars
25642573
- shape(N,): symmetric +/- values for each bar
@@ -2567,8 +2576,8 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
25672576
errors.
25682577
- *None*: No errorbar. (default)
25692578
2570-
See :doc:`/gallery/statistics/errorbar_features`
2571-
for an example on the usage of ``xerr`` and ``yerr``.
2579+
See :doc:`/gallery/statistics/errorbar_features` for an example on
2580+
the usage of *xerr* and *yerr*.
25722581
25732582
ecolor : color or list of color, default: 'black'
25742583
The line color of the errorbars.
@@ -2577,13 +2586,17 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
25772586
The length of the error bar caps in points.
25782587
25792588
error_kw : dict, optional
2580-
Dictionary of kwargs to be passed to the `~.Axes.errorbar`
2581-
method. Values of *ecolor* or *capsize* defined here take
2582-
precedence over the independent kwargs.
2589+
Dictionary of keyword arguments to be passed to the
2590+
`~.Axes.errorbar` method. Values of *ecolor* or *capsize* defined
2591+
here take precedence over the independent keyword arguments.
25832592
25842593
log : bool, default: False
25852594
If ``True``, set the x-axis to be log scale.
25862595
2596+
data : indexable object, optional
2597+
If given, all parameters also accept a string ``s``, which is
2598+
interpreted as ``data[s]`` (unless this raises an exception).
2599+
25872600
**kwargs : `.Rectangle` properties
25882601
25892602
%(Rectangle:kwdoc)s
@@ -2596,12 +2609,11 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
25962609
-----
25972610
Stacked bars can be achieved by passing individual *left* values per
25982611
bar. See
2599-
:doc:`/gallery/lines_bars_and_markers/horizontal_barchart_distribution`
2600-
.
2612+
:doc:`/gallery/lines_bars_and_markers/horizontal_barchart_distribution`.
26012613
"""
26022614
kwargs.setdefault('orientation', 'horizontal')
26032615
patches = self.bar(x=left, height=height, width=width, bottom=y,
2604-
align=align, **kwargs)
2616+
align=align, data=data, **kwargs)
26052617
return patches
26062618

26072619
def bar_label(self, container, labels=None, *, fmt="%g", label_type="edge",

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,9 +2367,12 @@ def barbs(*args, data=None, **kwargs):
23672367

23682368
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
23692369
@_copy_docstring_and_deprecators(Axes.barh)
2370-
def barh(y, width, height=0.8, left=None, *, align='center', **kwargs):
2370+
def barh(
2371+
y, width, height=0.8, left=None, *, align='center',
2372+
data=None, **kwargs):
23712373
return gca().barh(
2372-
y, width, height=height, left=left, align=align, **kwargs)
2374+
y, width, height=height, left=left, align=align,
2375+
**({"data": data} if data is not None else {}), **kwargs)
23732376

23742377

23752378
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.