pandas.io.formats.style.Styler.bar
- Styler.bar(subset=None, axis=0, color='#d65f5f', width=100, align='left', vmin=None, vmax=None)[source]
-
Draw bar chart in the cell backgrounds.
- Parameters
-
- subset:label, array-like, IndexSlice, optional
-
A valid 2d input to DataFrame.loc[<subset>], or, in the case of a 1d input or single key, to DataFrame.loc[:, <subset>] where the columns are prioritised, to limit
data
to before applying the function. - axis:{0 or ‘index’, 1 or ‘columns’, None}, default 0
-
Apply to each column (
axis=0
or'index'
), to each row (axis=1
or'columns'
), or to the entire DataFrame at once withaxis=None
. - color:str or 2-tuple/list
-
If a str is passed, the color is the same for both negative and positive numbers. If 2-tuple/list is used, the first element is the color_negative and the second is the color_positive (eg: [‘#d65f5f’, ‘#5fba7d’]).
- width:float, default 100
-
A number between 0 or 100. The largest value will cover width percent of the cell’s width.
- align:{‘left’, ‘zero’,’ mid’}, default ‘left’
-
How to align the bars with the cells.
‘left’ : the min value starts at the left of the cell.
‘zero’ : a value of zero is located at the center of the cell.
‘mid’ : the center of the cell is at (max-min)/2, or if values are all negative (positive) the zero is aligned at the right (left) of the cell.
- vmin:float, optional
-
Minimum bar value, defining the left hand limit of the bar drawing range, lower values are clipped to vmin. When None (default): the minimum value of the data will be used.
- vmax:float, optional
-
Maximum bar value, defining the right hand limit of the bar drawing range, higher values are clipped to vmax. When None (default): the maximum value of the data will be used.
- Returns
-
- self:Styler
© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/api/pandas.io.formats.style.Styler.bar.html