Python | Introduction to Matplotlib
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. It was introduced by John Hunter in the year 2002.
One of the greatest benefits of visualization is that it allows us visual access to huge amounts of data in easily digestible visuals. Matplotlib consists of several plots like line, bar, scatter, histogram etc.
Installation :
Windows, Linux and macOS distributions have matplotlib and most of its dependencies as wheel packages. Run the following command to install matplotlib package :
python -mpip install -U matplotlib
Importing matplotlib :
from matplotlib import pyplot as plt
or
import matplotlib.pyplot as plt Basic plots in Matplotlib :
Matplotlib comes with a wide variety of plots. Plots helps to understand trends, patterns, and to make correlations. They’re typically instruments for reasoning about quantitative information. Some of the sample plots are covered here.
Line plot :
# importing matplotlib module from matplotlib import pyplot as plt # x-axis valuesx = [5, 2, 9, 4, 7] # Y-axis valuesy = [10, 5, 8, 4, 2] # Function to plotplt.plot(x,y) # function to show the plotplt.show() |
Output :

Bar plot :
# importing matplotlib module from matplotlib import pyplot as plt # x-axis valuesx = [5, 2, 9, 4, 7] # Y-axis valuesy = [10, 5, 8, 4, 2] # Function to plot the barplt.bar(x,y) # function to show the plotplt.show() |
Output :
Histogram :
# importing matplotlib module from matplotlib import pyplot as plt # Y-axis valuesy = [10, 5, 8, 4, 2] # Function to plot histogramplt.hist(y) # Function to show the plotplt.show() |
Output :

# importing matplotlib module from matplotlib import pyplot as plt # x-axis valuesx = [5, 2, 9, 4, 7] # Y-axis valuesy = [10, 5, 8, 4, 2] # Function to plot scatterplt.scatter(x, y) # function to show the plotplt.show() |
Output :

Reference : Matplotlib Documentation.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


