Skip to content

Commit 5bf23fd

Browse files
authored
Merge pull request matplotlib#31395 from turbotimon/doc-mention-bar_label
doc: mention `bar_label` in `bar` and `barh`
1 parent 443c728 commit 5bf23fd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,11 +2390,13 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23902390
23912391
label : str or list of str, optional
23922392
A single label is attached to the resulting `.BarContainer` as a
2393-
label for the whole dataset.
2393+
legend label for the whole dataset.
23942394
If a list is provided, it must be the same length as *x* and
23952395
labels the individual bars. Repeated labels are not de-duplicated
23962396
and will cause repeated label entries, so this is best used when
2397-
bars also differ in style (e.g., by passing a list to *color*.)
2397+
bars also differ in style (e.g., by passing a list to *color*).
2398+
2399+
Tip: Use `.bar_label` to place labels on the bars.
23982400
23992401
xerr, yerr : float or array-like of shape(N,) or shape(2, N), optional
24002402
If not *None*, add horizontal / vertical errorbars to the bar tips.
@@ -2435,6 +2437,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
24352437
--------
24362438
barh : Plot a horizontal bar plot.
24372439
grouped_bar : Plot multiple datasets as grouped bar plot.
2440+
bar_label : Add labels to bars.
24382441
24392442
Notes
24402443
-----
@@ -2730,11 +2733,13 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
27302733
27312734
label : str or list of str, optional
27322735
A single label is attached to the resulting `.BarContainer` as a
2733-
label for the whole dataset.
2734-
If a list is provided, it must be the same length as *y* and
2736+
legend label for the whole dataset.
2737+
If a list is provided, it must be the same length as *x* and
27352738
labels the individual bars. Repeated labels are not de-duplicated
27362739
and will cause repeated label entries, so this is best used when
2737-
bars also differ in style (e.g., by passing a list to *color*.)
2740+
bars also differ in style (e.g., by passing a list to *color*).
2741+
2742+
Tip: Use `.bar_label` to place labels on the bars.
27382743
27392744
xerr, yerr : float or array-like of shape(N,) or shape(2, N), optional
27402745
If not *None*, add horizontal / vertical errorbars to the bar tips.
@@ -2775,6 +2780,7 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
27752780
See Also
27762781
--------
27772782
bar : Plot a vertical bar plot.
2783+
bar_label : Add labels to bars.
27782784
27792785
Notes
27802786
-----

0 commit comments

Comments
 (0)