How to Create a Line Plot with Matplotlib

12.15.2020

Intro

Line plots are one of the fundamental plots that you will use in data analysis. They are great for viewing the relationship between two continuous variables (and some times more). In this article, we will show you how to create a simple line plot using the Matplotlib pacakge.

Creating the Line Plot

For our example, let's create two arrays of height and weight. These are values are fake data, but will help us view a normal use case for line plots. We will plot height on the x-axis and weight on the y-axis so we can view the relationship between the two variables.

import matplotlib.pyplot as plt

height = [55, 60, 65, 65, 66, 70]
weight = [150, 155, 170, 172, 180, 185]

plt.plot(height, weight)
plt.show()