pandas.io.formats.style.Styler.bar

pandas 3.1.1 · Styling · method

Draw a horizontal bar within each numeric table cell to visualize its value.

Call syntax

Styler.bar(…) Full signature
Styler.bar(
    subset=None,
    axis=0,
    *,
    color=None,
    cmap=None,
    width=100,
    height=100,
    align='mid',
    vmin=None,
    vmax=None,
    props='width: 10em;',
)

Inspect the call

Run this code to inspect the callable and its parameters. Its data, backend, or environment is needed to execute the operation itself.

Parameters

ParameterRequirementAccepted values and behavior
subset Optional
Positional or keyword
Default None
label, array-like, IndexSlice

Restrict the operation to these labels instead of considering the whole object.

axis Optional
Positional or keyword
Default 0
{0 or 'index', 1 or 'columns', None}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

color Optional
Keyword only
Default None
str or 2-tuple/list

Choose the color or colors for the plot or styled cells.

cmap Optional
Keyword only
Default None
str, matplotlib.cm.ColorMap

Choose the color map used to translate values to colors.

width Optional
Keyword only
Default 100
float

Set the requested width of the formatted result.

height Optional
Keyword only
Default 100
float
align Optional
Keyword only
Default 'mid'
str, int, float, callable
vmin Optional
Keyword only
Default None
float

Set the lower boundary for the color range or normalization.

vmax Optional
Keyword only
Default None
float

Set the upper boundary for the color range or normalization.

props Optional
Keyword only
Default 'width: 10em;'
str

Supply CSS property declarations or the styles applied to matching cells.

Returns

Styler

Example for a local Python session

import pandas as pd
import matplotlib
import jinja2
frame = pd.DataFrame({"units": [2., 5., 7.], "price": [4., 3., 2.]})
styled = frame.style
print(styled.bar())