Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Plotting histograms against classes in Pandas / Matplotlib
To plot histograms against classes in Pandas/Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a potentially hetrogeneous tabular data using Pandas dataframe.
Make a histogram from the DataFrame values.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt
import pandas as pd
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
df = pd.DataFrame({'a': [1, 1, 1, 1, 3],'b': [1, 1, 2, 1, 3],'c': [2, 2, 2, 1, 3],
'd': [2, 1, 2, 1, 3],})
df.hist()
plt.show()
Output

Advertisements
