w3resource

Pandas DataFrame: plot.bar() function

DataFrame.plot.bar() function

The plot.bar() function is used to vertical bar plot.

A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being compared, and the other axis represents a measured value.

Syntax:

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

Parameters:

Name Description Type/Default Value Required / Optional
x             Allows plotting of one column versus another. If not specified, the index of the DataFrame is used. label or position Optional
y 

Allows plotting of one column versus another. If not specified, all numerical columns are used.

label or position
Optional
**kwds   Additional keyword arguments are documented inDataFrame.plot().   Required

Returns: matplotlib.axes.Axes or np.ndarray of them An ndarray is returned with one matplotlib.axes.Axes per column when subplots=True.

Example:


Download the Pandas DataFrame Notebooks from here.

PREV : DataFrame.plot.area() function
NEXT : DataFrame.plot.barh() function



Follow us on Facebook and Twitter for latest update.