Matplotlib Bar Plot – Tutorial and Examples
Introduction
Matplotlib is one of the most widely used data visualization libraries in Python. From simple to complex visualizations, it’s the go-to library for most.
In this tutorial, we’ll take a look at how to plot a bar plot in Matplotlib.
Bar graphs display numerical quantities on one axis and categorical variables on the other, letting you see how many occurrences there are for the different categories.
Bar charts can be used for visualizing a time series, as well as just categorical data.
Plot a Bar Plot in Matplotlib
Plotting a Bar Plot in Matplotlib is as easy as calling the bar()
function on the PyPlot instance, and passing in the categorical and continuous variables that we’d like to visualize.
import matplotlib.pyplot as plt
x = ['A', 'B', 'C']
y = [1, 5, 3]
plt.bar(x, y)
plt.show()
Here, we’ve got a few