لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Python Data Science Machine Learning Lesson 6: Scatter Plot

A scatter plot is a graph where each value in the data set is represented as a dot.
The Matplotlib module has a method for plotting scatter plots, the two arrays should be of same length, one represents the values of x-axis, the other represents values of the y-axis.

Example: Consider the speed of 10 different trains as under.
These 10 different trains passes thorugh the station at different time.

speed = [92, 90, 95, 97, 85, 99, 88, 97, 84, 101]
time = [7, 8, 9, 12, 10, 5, 6, 11, 4, 8]

In Python programming language you have a module called matplotlib to plot the scatter plot.
You have to first import matplotlib as under

import matplotlib.pyplot as plt

Now, the code in python programming will be as under

code

import matplotlib.pyplot as plt
speed = [92, 90, 95, 97, 85, 99, 88, 97, 84, 101]
time = [7, 8, 9, 12, 10, 5, 6, 11, 4, 8]
plt.scatter(speed,time)
plt.show()

The output will be:

Conclusion:
The x-axis represents speed, and the y-axis represents time.
It can be concluded from the above scatter plot:

1. The speed of the train was maximum at time 8pm.
2. The speed of the train was minimum at time 4 pm.

Note: if you have python installed on your pc you can install matplotlib as under.
Open Command Prompt from the start menu.
Inside the command prompt, type
pip install matplotlib
press enter
This command will install matplotlib on your computer after which you can run on python.