pandas.io.formats.style.Styler.background_gradient¶
-
Styler.
background_gradient
(cmap=’PuBu’, low=0, high=0, axis=0, subset=None)[source]¶ Color the background in a gradient according to the data in each column (optionally row). Requires matplotlib.
New in version 0.17.1.
Parameters: cmap: str or colormap
matplotlib colormap
low, high: float
compress the range by these values.
axis: int or str
1 or ‘columns’ for columnwise, 0 or ‘index’ for rowwise
subset: IndexSlice
a valid slice for
data
to limit the style application toReturns: self : Styler
Notes
Tune
low
andhigh
to keep the text legible by not using the entire range of the color map. These extend the range of the data bylow * (x.max() - x.min())
andhigh * (x.max() - x.min())
before normalizing.