Python for Introductory StatisticsXYZ Homework Edition

⇩ Download ▾

5.7 Scatter Plots

Watch demo video

A data set with a pair of quantitative variables can be displayed with a scatter plot.

Example: Age in years and the corresponding height in centimeters is given below. Draw a scatter plot.

age(yrs)Height(cm)
595
6100
7105
8107
9110
10115
  1. Click + Code
  2. Type import matplotlib.pyplot as plt
  3. Type x = [5,6,7,8,9,10]
  4. Type y = [95,100,105,107,110,115]
  5. Type plt.scatter(x,y)
  6. Type plt.suptitle('Scatter Plot Age vs Height')
  7. Type plt.xlabel('Age(yrs)')
  8. Type plt.ylabel('Height(cm)')
  9. Click play button
import matplotlib.pyplot as plt

x = [5,6,7,8,9,10]
y = [95,100,105,107,110,115]

plt.scatter(x,y)

plt.suptitle('Scatter Plot Age vs Height')
plt.xlabel('Age(yrs)')
plt.ylabel('Height(cm)')
Show expected output
Text(0, 0.5, 'Height(cm)')
Scatter plot titled Scatter Plot Age vs Height: six points rising steadily from (5, 95) to (10, 115); axes labeled Age(yrs) and Height(cm).

Adapted from Python for Introductory Statistics, by Simon Aman (Truman College, City Colleges of Chicago), licensed under CC BY 4.0. Changes were made: reformatted as an accessible XYZ web edition with live in-browser code cells. License: CC-BY-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.