pandas.DataFrame.plot.bar

pandas 3.1.1 · DataFrame · method

Draw vertical bars for category comparisons.

Call syntax

DataFrame.plot.bar(x=None, y=None, color=None, **kwargs)

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
x Optional
Positional or keyword
Default None
label or position

Choose the column or positional input mapped to the horizontal axis.

y Optional
Positional or keyword
Default None
label or position

Choose the column or positional input mapped to the vertical axis.

color Optional
Positional or keyword
Default None
str, array-like, or dict

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

**kwargs Optional
Additional keyword arguments

Returns

matplotlib.axes.Axes or numpy.ndarray of them

Example for a local Python session

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