Skip to main content

The coordinate plane

Two number lines crossed at right angles turn every point of a page into a pair of numbers. Learn to plot and read ordered pairs, find the change from one point to another and the midpoint between them, and turn a table of data into a scatter plot.
M01.2.1L0 Foundation25 minIn review

Before this lesson

M01.1 Numbers, algebra and notation P01.6 Lists, tuples, dictionaries and sets (planned)

After this lesson you can

  • Plot a point from its ordered pair, read the pair of a plotted point, and name its quadrant from the two signs.
  • Explain why the order of an ordered pair matters, using the points (1, 2) and (2, 1).
  • Compute the horizontal and the vertical change from one point to another, keeping their signs.
  • Find the midpoint of two points, and the mean point of a data set, by averaging coordinates.

In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.

The question

Here are four pairs of numbers: (1, 2), (2, 3), (3, 5) and (4, 6). Each pair could be the hours someone studied and the mark they got, or the size of a flat and its rent. Read as a list, they are just numbers. Drawn as four dots, they show at a glance that the second number grows with the first. How does a pair of numbers become a dot on a page, and a dot become a pair of numbers? And once numbers are places, what can we work out between them?

Intuition

Lesson M01.1.1 put every number on a line: a point for each number, negative numbers to the left of zero and positive numbers to the right. One line holds one number. To hold two numbers, take two number lines and cross them at right angles, at the point where both read zero.

  • The flat line is the x-axis. It measures across: right is positive, left is negative.
  • The upright line is the y-axis. It measures up: up is positive, down is negative.
  • The point where they cross is the origin. It reads zero on both lines.

Now every point of the page has an address made of two numbers. To reach the point \(P\) in the figure, start at the origin, walk 1 across, then walk 2 up. We write \({P = (1, 2)}\): the across number first, the up number second.

A coordinate plane on a light grid. A horizontal axis labelled x-axis, across, and an upright axis labelled y-axis, up, cross at a dot labelled origin (0, 0). The axes are numbered from minus 2 to 4 across and minus 1 to 3 up. From the origin a green arrow labelled 1 across runs along the x-axis to 1, and a second green arrow labelled 2 up rises from there to a blue dot labelled P = (1, 2). A dashed line from P to the y-axis shows that P sits at height 2.
M01.2.1-F1

The point \({P = (1, 2)}\): start at the origin, go 1 across, then 2 up. The first number is read on the x-axis and the second on the y-axis.

That is the whole idea: a pair of numbers is a place, and a place is a pair of numbers. Draw the pairs of a table as dots and you have a scatter plot. Machine learning looks at a data table in the same way. Each row becomes a dot, and the page becomes a map of the data on which nearby dots are similar examples.

Build it up

Step 1. Coordinates. The two numbers that name a point are its coordinates. In \({P = (1, 2)}\), the number 1 is the x-coordinate and 2 is the y-coordinate. The pair is an ordered pair, because its order carries meaning. \((1, 2)\) means 1 across and 2 up. \((2, 1)\) means 2 across and 1 up, which is a different point. Swap the numbers and the point moves.

Step 2. Signs. A negative x-coordinate means walk left, and a negative y-coordinate means walk down. So \({(-3, 2)}\) is 3 to the left and 2 up. A zero means do not move that way: \((0, 5)\) sits on the y-axis and \((4, 0)\) sits on the x-axis.

Step 3. Quadrants. The two axes cut the plane into four regions called quadrants. They are numbered I to IV, going anticlockwise from the top right. The two signs alone tell you which quadrant a point is in.

A coordinate plane numbered from minus 4 to 4 in both directions, with the four quadrants labelled in their corners: I with signs plus, plus at the top right, II with minus, plus at the top left, III with minus, minus at the bottom left and IV with plus, minus at the bottom right. Four blue points are marked with their pairs: (3, 2) in quadrant I, (minus 4, 1) in quadrant II, (minus 2, minus 3) in quadrant III and (4, minus 2) in quadrant IV. A fifth point, (0, minus 3), sits on the y-axis and is labelled on an axis, in no quadrant.
M01.2.1-F2

The signs of the two coordinates name the quadrant. A point with a zero coordinate lies on an axis and belongs to no quadrant.

Step 4. From one point to another. Take \({P = (1, 2)}\) and \({Q = (4, 6)}\). To walk from \(P\) to \(Q\) you go some way across and some way up. Each amount is a subtraction, end minus start:

\[ \begin{aligned} \text{horizontal change} &= 4 - 1 = 3, \\ \text{vertical change} &= 6 - 2 = 4 . \end{aligned} \]

So the walk from \(P\) to \(Q\) is 3 across and 4 up. The two changes keep their signs. The walk back, from \(Q\) to \(P\), is

\[ \begin{aligned} 1 - 4 &= -3 \text{ across}, \\ 2 - 6 &= -4 \text{ up}, \end{aligned} \]

that is, 3 to the left and 4 down. The horizontal change is also called the run and the vertical change the rise. Lesson M01.3.2 uses those names for the slope of a line.

Step 5. Halfway. From \(P\), walk half of each change: 1.5 across and 2 up. You land on

\[ (1 + 1.5,\; 2 + 2) = (2.5,\; 4), \]

the point halfway between \(P\) and \(Q\). It is called the midpoint. Look at its two numbers: 2.5 is the average of 1 and 4, and 4 is the average of 2 and 6. The midpoint is the average of the two points, one coordinate at a time.

Two panels, each a numbered grid with the blue point P = (1, 2) and the sky-blue point Q = (4, 6). Left panel, titled From P to Q: a dashed green line runs across from P to the point (4, 2), labelled across, 4 minus 1 equals 3, and a dashed green line runs up from there to Q, labelled up, 6 minus 2 equals 4, with a small square marking the right angle. Right panel, titled Half of each change: from P a dashed green line runs 1.5 across and then 2 up, ending at a vermillion dot labelled M = (2.5, 4), which sits exactly halfway along the thin line from P to Q.
M01.2.1-F3

Left: the walk from \(P\) to \(Q\) is 3 across and 4 up, each found by subtracting. Right: half of each change, walked from \(P\), lands on the midpoint \({M = (2.5, 4)}\).

The formal statement

NoteDefinition: the coordinate plane

The coordinate plane is a flat plane with two number lines at right angles: the horizontal x-axis and the vertical y-axis, crossing at the origin \((0, 0)\). Each point \(P\) is named by an ordered pair \({P = (p_1, p_2)}\) of its x-coordinate \(p_1\) and its y-coordinate \(p_2\). Two pairs name the same point exactly when their first coordinates agree and their second coordinates agree.

The small numbers are labels, as in lesson M01.1.4: \(p_1\) is the first coordinate of \(P\) and \(p_2\) is its second. A second point is written \({Q = (q_1, q_2)}\). Three results follow.

Result 1: the changes. From \(P\) to \(Q\),

\[ \begin{aligned} \text{horizontal change} &= q_1 - p_1, \\ \text{vertical change} &= q_2 - p_2 . \end{aligned} \]

Each is end minus start. Swapping the start and the end flips the sign of both.

Result 2: the midpoint. The midpoint \({M = (m_1, m_2)}\) is reached from \(P\) by half of each change. Its first coordinate is

\[ \begin{aligned} m_1 &= p_1 + \tfrac{1}{2}(q_1 - p_1) \\ &= p_1 + \tfrac{1}{2}q_1 - \tfrac{1}{2}p_1 \\ &= \tfrac{1}{2}p_1 + \tfrac{1}{2}q_1 \\ &= \frac{p_1 + q_1}{2} . \end{aligned} \]

The second line multiplies out the bracket (the distributive law of M01.1.2). The third line collects the two terms in \(p_1\): one whole \(p_1\) take away half of it leaves half of it. The same four lines with the second coordinates give \(m_2\), so

\[ M = \left( \frac{p_1 + q_1}{2},\; \frac{p_2 + q_2}{2} \right). \]

The answer does not change if \(P\) and \(Q\) swap places, so walking half the change back from \(Q\) lands on the same point.

Result 3: the mean point. For \(n\) points \((x_1, y_1)\), \((x_2, y_2)\), …, \((x_n, y_n)\), the mean point is \((\bar{x}, \bar{y})\), where

\[ \begin{aligned} \bar{x} &= \frac{x_1 + x_2 + \dots + x_n}{n}, \\ \bar{y} &= \frac{y_1 + y_2 + \dots + y_n}{n} . \end{aligned} \]

The bar means “the mean of”, as in M01.1.4. With \({n = 2}\) this is the midpoint formula again, so the midpoint is the mean point of two points.

Frontier note: centring a data set on its mean point

Many methods start by sliding a whole data set so that its mean point sits at the origin: subtract \(\bar{x}\) from every x-coordinate and \(\bar{y}\) from every y-coordinate. This is called centring. The course’s four points, whose mean point is \((2.5, 4)\) (worked below), become \({(-1.5, -2)}\), \({(-0.5, -1)}\), \((0.5, 1)\) and \((1.5, 2)\), and their new mean point is \((0, 0)\). Standardising features (ML01.3.3) and principal component analysis (M03.6) both begin with this step.

Worked example

The course’s four data points, from table to picture. The table has one row per example: an input \(x\) and a target \(y\).

Two panels. The left panel is a table with columns x and y and four rows: 1 and 2, 2 and 3, 3 and 5, 4 and 6, with a highlighted bottom row giving the means, 2.5 and 4. An arrow labelled plot each row leads to the right panel, a numbered grid with four blue dots at (1, 2), (2, 3), (3, 5) and (4, 6), each labelled with its pair. Thin dashed lines join (1, 2) to (4, 6) and (2, 3) to (3, 5). Both lines pass through a vermillion diamond labelled mean point (2.5, 4).
M01.2.1-F4

Each row of the table becomes one dot. The mean point \((2.5, 4)\) is also the midpoint of the outer pair and of the inner pair.

Plot the rows. Each row \((x, y)\) is a point: go \(x\) across and \(y\) up. Both coordinates of every point are positive, so all four dots lie in quadrant I.

Find the mean point. Add each column and divide by the number of rows:

\[ \begin{aligned} \bar{x} &= \frac{1 + 2 + 3 + 4}{4} = \frac{10}{4} = 2.5, \\ \bar{y} &= \frac{2 + 3 + 5 + 6}{4} = \frac{16}{4} = 4 . \end{aligned} \]

So the mean point is \((2.5, 4)\).

Compare it with a midpoint. The first point is \({P = (1, 2)}\) and the last is \({Q = (4, 6)}\). Their midpoint, from Step 5, is also \((2.5, 4)\). That is not luck. The two inner points have the midpoint

\[ \left( \frac{2 + 3}{2},\; \frac{3 + 5}{2} \right) = (2.5,\; 4) \]

as well. The data come in two pairs, each balanced around \((2.5, 4)\), so the average of all four is that same point.

Code

First from scratch. A point is a tuple, two numbers in round brackets, and Python counts its positions from 0: P[0] is the x-coordinate and P[1] is the y-coordinate.

P = (1, 2)              # the point P: across 1, up 2
Q = (4, 6)              # the point Q

across = Q[0] - P[0]    # horizontal change: end minus start
up = Q[1] - P[1]        # vertical change: end minus start
print("from P to Q:", across, "across and", up, "up")

midpoint = []                            # an empty list, filled one coordinate at a time
for k in range(2):                       # k is 0, then 1
    midpoint.append((P[k] + Q[k]) / 2)   # the average of the two coordinates
print("midpoint:", midpoint)
from P to Q: 3 across and 4 up
midpoint: [2.5, 4.0]

The mean point of the four data points takes one loop that walks the two lists together, as P01.6.2 does with zip.

xs = [1, 2, 3, 4]       # the x-coordinates of the four points
ys = [2, 3, 5, 6]       # their y-coordinates, in the same order

total_x = 0
total_y = 0
for x, y in zip(xs, ys):        # one point at a time
    total_x = total_x + x
    total_y = total_y + y
mean_point = (total_x / len(xs), total_y / len(ys))
print("mean point:", mean_point)
mean point: (2.5, 4.0)

Now the same with NumPy, as a preview of P02. One array holds the whole table, with a row per point and a column per coordinate.

import numpy as np

points = np.array([[1, 2],
                   [2, 3],
                   [3, 5],
                   [4, 6]])     # one row per point
print(points.shape)             # (rows, columns)
print(points.mean(axis=0))      # axis=0 averages down each column
(4, 2)
[2.5 4. ]

The shape (4, 2) says 4 points with 2 coordinates each, and the column means are the mean point. Drawing the scatter plot takes two lines of Matplotlib, which P02.8 teaches. They are shown here, not run; figure M01.2.1-F4 was drawn by a longer script of the same kind.

import matplotlib.pyplot as plt
plt.scatter(xs, ys)     # one dot for each (x, y) pair

Every scatter plot rests on this lesson, and so does every feature space in machine learning: a table with two numeric columns is a set of points in the plane.

Explore

This module’s interactive, the point and arrow explorer, lives in lesson M01.2.4, where it also shows arrows. You can use it now: drag the two points, or move their sliders, and watch the horizontal change, the vertical change and the midpoint update.

Pitfalls

Two panels side by side, each a small numbered grid. The left panel is marked with a cross and titled Up first: wrong. From the origin a purple arrow goes 1 up and then 2 across, ending at a hollow purple dot labelled lands on (2, 1), while a hollow blue dot at (1, 2) is labelled P is here. The right panel is marked with a tick and titled Across first: right. From the origin a green arrow goes 1 across and then 2 up, ending at a blue dot labelled P = (1, 2).
M01.2.1-F5

Wrong beside right. Reading the pair as “up, then across” lands on \((2, 1)\), a different point. The first number is always the across number.

“\((1, 2)\) and \((2, 1)\) contain the same numbers, so they are the same point.”

The order is part of the address. The first number is how far across and the second how far up, so \((1, 2)\) and \((2, 1)\) sit in different places. Swapping the two columns of a data table would move every one of its dots.

“A change is a length, so it can never be negative.”

A change keeps its sign, because it says which way to go. From \({Q = (4, 6)}\) to \({P = (1, 2)}\) the changes are \({-3}\) across and \({-4}\) up. A distance is never negative, and lesson M01.2.3 builds one from these changes, but the changes themselves can be.

“Half the change is the midpoint.”

Half of each change, 1.5 across and 2 up, tells you how far to walk from \(P\). The midpoint is where you land: \((2.5, 4)\). A quick check catches the slip. Each coordinate of the midpoint is equally far from the matching coordinates of the two points: 2.5 is 1.5 away from both 1 and 4, and 4 is 2 away from both 2 and 6. The wrong answer \((1.5, 2)\) fails at once, because 2 is no distance from 2 but 4 away from 6.

“P[1] is the first coordinate.”

In maths the first coordinate of \(P\) is \(p_1\). In Python it is P[0], because Python counts from 0 (M01.1.4). P[1] is the second coordinate, the y-coordinate.

Check yourself

Recall

1. In the ordered pair \((x, y)\), which number tells you how far across and which tells you how far up?

Show answer

The first number, \(x\), is how far across. The second number, \(y\), is how far up.

2. Which quadrant holds the point \({(-3, 2)}\), and why?

Show answer

Quadrant II. Its x-coordinate is negative (left of the y-axis) and its y-coordinate is positive (above the x-axis), the sign pattern \({(-, +)}\).

3. What are the horizontal and the vertical change from \((4, 6)\) to \((1, 2)\)?

Show answer

End minus start:

\[ \begin{aligned} 1 - 4 &= -3 \text{ across}, \\ 2 - 6 &= -4 \text{ up}. \end{aligned} \]

That is 3 to the left and 4 down.

4. What is the midpoint of \({(-2, 5)}\) and \((4, 1)\)?

Show answer

Average each coordinate:

\[ \left( \frac{-2 + 4}{2},\; \frac{5 + 1}{2} \right) = (1,\; 3). \]

5. What is the mean point of a set of points?

Show answer

The point whose x-coordinate is the mean of all the x-coordinates and whose y-coordinate is the mean of all the y-coordinates.

Exercises

1. ★ Say where each point lies: in which quadrant, or on which axis. \({A = (3, -1)}\), \({B = (-2, -4)}\), \({C = (0, 5)}\), \({D = (-0.5, 2)}\).

Show solution

\(A\) has signs \({(+, -)}\), so it is in quadrant IV. \(B\) has \({(-, -)}\), so it is in quadrant III. \(C\) has x-coordinate 0, so it lies on the y-axis and in no quadrant. \(D\) has \({(-, +)}\), so it is in quadrant II.

2. ★★ Let \({P = (-1, 3)}\) and \({Q = (5, -1)}\). Find the horizontal and the vertical change from \(P\) to \(Q\), and the midpoint \(M\). Check \(M\) by walking half of each change from \(P\).

Show solution

End minus start:

\[ \begin{aligned} \text{across} &= 5 - (-1) = 6, \\ \text{up} &= -1 - 3 = -4 . \end{aligned} \]

So the walk is 6 across and 4 down. The midpoint averages each coordinate:

\[ \begin{aligned} m_1 &= \frac{-1 + 5}{2} = 2, \\ m_2 &= \frac{3 + (-1)}{2} = 1, \end{aligned} \]

so \({M = (2, 1)}\).

Check: half of each change is 3 across and \({-2}\) up. From \(P\) that lands on

\[ (-1 + 3,\; 3 - 2) = (2,\; 1), \]

the same point.

3. ★★★ The point \({M = (2.5, 4)}\) is the midpoint of \({P = (1, 2)}\) and a point \(Q\) that has been lost. Find \(Q\). Then find a rule that gives \(Q\) from any \(P\) and \(M\).

Show solution

From \(P\) to \(M\) the changes are

\[ \begin{aligned} 2.5 - 1 &= 1.5 \text{ across}, \\ 4 - 2 &= 2 \text{ up}. \end{aligned} \]

That is half of the walk from \(P\) to \(Q\), so the whole walk is 3 across and 4 up, and

\[ Q = (1 + 3,\; 2 + 4) = (4,\; 6). \]

For the rule, start from the midpoint formula and undo it one step at a time:

\[ \begin{aligned} m_1 &= \frac{p_1 + q_1}{2} \\ 2m_1 &= p_1 + q_1 \\ q_1 &= 2m_1 - p_1 . \end{aligned} \]

The same steps with the second coordinates give \({q_2 = 2m_2 - p_2}\). In words: double the midpoint and take away the known end. Check both with the numbers:

\[ \begin{aligned} q_1 &= 2 \times 2.5 - 1 = 4, \\ q_2 &= 2 \times 4 - 2 = 6 . \end{aligned} \]

Summary card

A point is two numbers: how far across, then how far up.

The anchor figure again: a numbered coordinate plane with its origin, and green arrows walking 1 across and then 2 up from the origin to the blue point P = (1, 2).
M01.2.1-F1

Across first, then up.

  • A point: \({P = (p_1, p_2)}\), the x-coordinate first. The signs give the quadrant.
  • Change from \(P\) to \(Q\): \({q_1 - p_1}\) across and \({q_2 - p_2}\) up, signs kept.
  • Midpoint: the average of the two points, one coordinate at a time.
  • Mean point: \((\bar{x}, \bar{y})\), the average of all the points.

Sources and next steps

Sources. Each was opened and checked against this lesson on 12 November 2026.

  • OpenStax, Prealgebra 2e, Section 11.1, “Use the Rectangular Coordinate System”. It defines the axes, the origin and the ordered pair, notes that the order of the coordinates matters with \((1, 3)\) and \((3, 1)\), numbers the quadrants anticlockwise from the upper right and tabulates their signs.
  • OpenStax, Algebra and Trigonometry 2e, Section 2.1, “The Rectangular Coordinate Systems and Graphs”. It gives the midpoint formula under “Using the Midpoint Formula”.
  • Marc Peter Deisenroth, A. Aldo Faisal and Cheng Soon Ong, Mathematics for Machine Learning, Section 8.1.1, “Data as Vectors”. Each row of a data table is one example and each column one feature, so each example is a list of numbers, one per feature.
  • NumPy, numpy.mean. The axis argument; its example np.mean(a, axis=0) for the rows [1, 2] and [3, 4] gives [2., 3.], the mean of each column.

Next. M01.2.2 Right triangles and Pythagoras’ theorem turns the walk of 3 across and 4 up into a straight-line distance.

This lesson unlocks

M01.2.2 Right triangles and Pythagoras' theorem

Your progress is saved in this browser only. No account, no tracking.
Back to top