Matplotlib Line 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 line plot in Matplotlib – one of the most basic types of plots.
Line Plots display numerical values one one axis, and categorical values on the other. They can typically be used in much the same way Bar Plots can be used, though, they’re more commonly used to keep track of changes over time.
Plot a Line Plot in Matplotlib
To plot a line plot in Matplotlib, you use the generic plot()
function from the PyPlot instance. There’s no specific lineplot()
function – the generic one automatically plots using lines or markers.
Let’s make our own small dataset to work with:
import matplotlib.pyplot as plt
x =