Python for Introductory StatisticsXYZ Homework Edition

⇩ Download ▾

12.1 Scatter plot

One way to check for a relationship between two variables is to draw a scatter plot. One of the variables (independent/explanatory) can be on the x-axis and the dependent(response) on the y-axis. To draw a scatterplot of two variables x and y use the following code

import matplotlib.pyplot as plt
x = [x1,x2,...]
y = [y1,y2,...]
plt.scatter(x, y)

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.