Best Practice to Implement Scatter Plot with Matplotlib – Matplotlib Tutorial

By | July 9, 2019

Scatter plot can show the distribution of a pair of data on a two-dimensional plane, which is very useful for us to observe the feature of data. In this tutorial, we will write an example to show how to implement a scatter plot using matplotlib.

Preliminaries

#-*- coding: UTF-8 -*- 
import matplotlib.pyplot as plt

Create a pair of data (x, y)

x = [1, 8, 3, 4, 5, 6, 7, 2, 9, 10]
y = [1, 5, 8, 7, 10, 9, 3, 6, 2, 4]

Create a scatter plot and show it

plt.scatter(x, y)
plt.show()

The scatter plot is like:

matplotlib scatter plot

Leave a Reply

Your email address will not be published. Required fields are marked *