Plotting Bar Charts - Pyplot of Mathplotlib module

Author: Al-mamun Sarkar Date: 2020-04-02 07:28:06

Plotting Bar Charts - Pyplot of Mathplotlib module. The following codes shows how to plot a bar chart using pyplot of python mathplotlib module.

 

Import Module:

import matplotlib.pyplot as plt

Create data and plot bar chart:

x_data = [2, 4, 6, 8, 10]
y_data = [6, 7, 8, 2, 4]
plt.bar(x_data, y_data, label='Bar Chart')
plt.title("Welcome to bar chart ploting tutorial \n This is Another Line")
plt.xlabel('Plot Number on X-Axis')
plt.ylabel('Important Var on Y-Axis')
plt.legend()
plt.show()