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.
Previous: DataFrame.plot.area() function
Next: DataFrame.plot.barh() function
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework