How to Create a Scatter Plot with Matplotlib

2020-12-17

Intro

Scatter plots help you compare to variables and check for a trend or correlation. This is very helpful when trying to see if two variables are linearly related or not. In this article, we will see how to create a Scatter Plot using MatPlotLib

Creating the Scatter Plot

A common scatter plot is to check properties compared to price. Let's look at a small example (with fake data) comparing the size of a house to the price of a house. In this example we can see a clear linear trend, that as the size of the house increases, the price increases.

import matplotlib.pyplot as plt

houseSqFt = [1000, 1500, 2000, 25000]
price = [100000, 150000, 200000, 250000]

plt.scatter(houseSqFt, price)
plt.show()
GoTea - KoalaTea