MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / bar_label

Method bar_label

lib/matplotlib/axes/_axes.py:2798–2969  ·  view source on GitHub ↗

Label a bar plot. Adds labels to bars in the given `.BarContainer`. You may need to adjust the axis limits to fit the labels. Parameters ---------- container : `.BarContainer` Container with all the bars and optionally errorbars, likely

(self, container, labels=None, *, fmt="%g", label_type="edge",
                  padding=0, **kwargs)

Source from the content-addressed store, hash-verified

2796 return patches
2797
2798 def bar_label(self, container, labels=None, *, fmt="%g", label_type="edge",
2799 padding=0, **kwargs):
2800 """
2801 Label a bar plot.
2802
2803 Adds labels to bars in the given `.BarContainer`.
2804 You may need to adjust the axis limits to fit the labels.
2805
2806 Parameters
2807 ----------
2808 container : `.BarContainer`
2809 Container with all the bars and optionally errorbars, likely
2810 returned from `.bar` or `.barh`.
2811
2812 labels : array-like, optional
2813 A list of label texts, that should be displayed. If not given, the
2814 label texts will be the data values formatted with *fmt*.
2815
2816 fmt : str or callable, default: '%g'
2817 An unnamed %-style or {}-style format string for the label or a
2818 function to call with the value as the first argument.
2819 When *fmt* is a string and can be interpreted in both formats,
2820 %-style takes precedence over {}-style.
2821
2822 .. versionadded:: 3.7
2823 Support for {}-style format string and callables.
2824
2825 label_type : {'edge', 'center'}, default: 'edge'
2826 The label type. Possible values:
2827
2828 - 'edge': label placed at the end-point of the bar segment, and the
2829 value displayed will be the position of that end-point.
2830 - 'center': label placed in the center of the bar segment, and the
2831 value displayed will be the length of that segment.
2832 (useful for stacked bars, i.e.,
2833 :doc:`/gallery/lines_bars_and_markers/bar_label_demo`)
2834
2835 padding : float or array-like, default: 0
2836 Distance of label from the end of the bar, in points.
2837 If an array-like is provided, the padding values are applied
2838 to each label individually. Must have the same length as container.
2839 .. versionadded:: 3.11
2840
2841 **kwargs
2842 Any remaining keyword arguments are passed through to
2843 `.Axes.annotate`. The alignment parameters (
2844 *horizontalalignment* / *ha*, *verticalalignment* / *va*) are
2845 not supported because the labels are automatically aligned to
2846 the bars.
2847
2848 Returns
2849 -------
2850 list of `.Annotation`
2851 A list of `.Annotation` instances for the labels.
2852 """
2853 for key in ['horizontalalignment', 'ha', 'verticalalignment', 'va']:
2854 if key in kwargs:
2855 raise ValueError(

Calls 13

annotateMethod · 0.95
fmtFunction · 0.85
get_segmentsMethod · 0.80
sizeMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
intersectionMethod · 0.80
get_clip_boxMethod · 0.80
nullMethod · 0.80
get_view_intervalMethod · 0.45
get_pointsMethod · 0.45
get_bboxMethod · 0.45