Sub topic 5
Plotting and Reading Points
This chapter assumes you already know what the x-axis, y-axis and origin are. It also assumes you know how an ordered pair (x, y) is written and how to choose a scale for each axis. Here you put these ideas to work. You will place a point on the plane from its coordinates and read the coordinates of a point that is already drawn. You will also learn the errors that most often go wrong.
The working model
A point on the coordinate plane is the meeting place of two lines. One line is vertical and sits at a given x-value. The other is horizontal and sits at a given y-value. The ordered pair (x, y) gives both values, so it names exactly one meeting place.
The pair is read in two steps, always in this order:
- The first number, x, tells you how far to move horizontally from the origin. Positive means right. Negative means left.
- The second number, y, tells you how far to move vertically from where you stopped. Positive means up. Negative means down.
Plotting and reading are the same process run in opposite directions. When you plot, you start with numbers and finish with a mark. When you read, you start with a mark and finish with numbers.
Plotting a point step by step
Take the point (-4, 3).
- Begin at the origin, where the axes cross.
- The x-coordinate is -4. It is negative, so move 4 units to the left along the x-axis. Count in steps of the axis scale. If each tick mark is 1 unit, that is 4 ticks.
- The y-coordinate is 3. It is positive, so from that spot move 3 units up, parallel to the y-axis.
- Draw a dot where you stop. Write the pair (-4, 3) beside it.
You can also work in the other order, moving vertically first and then horizontally. You will land on the same point, because the two movements do not depend on each other. Even so, the convention is to move along x first. Following it keeps your method consistent with how the pair is written, so you are less likely to swap the numbers.
A worked example with several points
Plot A(2, 5), B(-3, 1), C(-2, -4) and D(5, -1).
- A(2, 5): 2 right, 5 up. This is in the upper right.
- B(-3, 1): 3 left, 1 up. This is in the upper left, close to the y-axis.
- C(-2, -4): 2 left, 4 down. This is in the lower left.
- D(5, -1): 5 right, 1 down. This is in the lower right, close to the x-axis.
Notice that each point's position matches its signs. The signs tell you which region of the plane to expect before you count a single unit. This is a quick check on your work, and the next chapter covers it in full.
Reading a point from a graph
To read the coordinates of a plotted point, reverse the plotting steps.
- From the point, go straight to the x-axis, moving only vertically. The number you reach is the x-coordinate.
- From the point, go straight to the y-axis, moving only horizontally. The number you reach is the y-coordinate.
- Write the pair as (x, y).
A common way to do this is to picture two lines from the point, one dropped vertically to the x-axis and one run horizontally to the y-axis. Where each line meets an axis gives you one coordinate.
For example, suppose a point sits directly above the tick marked 4 on the x-axis and level with the tick marked -2 on the y-axis. Its coordinates are (4, -2). If you cannot tell the value by eye, count ticks from the origin and multiply by the scale.
Reading with a scale other than 1
The scale decides what each tick is worth. Suppose the x-axis has a tick every 5 units and the y-axis has a tick every 2 units. A point that is 3 ticks right and 4 ticks up has the coordinates (15, 8), not (3, 4). Always check the numbers printed on the axes. Do not simply count squares.
Sometimes the point sits between ticks. If a point lies halfway between the 10 and 15 marks, its coordinate is 12.5. Estimate the fraction of the gap and add it to the lower tick. For hand-drawn work, an estimate is acceptable. When a problem says to give an exact value, the graph is normally drawn so that the points sit on grid intersections.
Checking a point with code
You can check which region a point falls in by testing the signs of its coordinates. This function returns the location of any point, including points on an axis or at the origin.
def locate(x, y):
if x == 0 and y == 0:
return "origin"
if y == 0:
return "on the x-axis"
if x == 0:
return "on the y-axis"
if x > 0 and y > 0:
return "quadrant I"
if x < 0 and y > 0:
return "quadrant II"
if x < 0 and y < 0:
return "quadrant III"
return "quadrant IV"
print(locate(3, 2))
print(locate(-4, 5))
print(locate(-1, -6))
print(locate(2, -3))
print(locate(0, 7))The output is:
quadrant I
quadrant II
quadrant III
quadrant IV
on the y-axisThe order of the tests matters. The zero cases are tested first. If you tested x > 0 and y > 0 before them, a point like (0, 7) would slip past every quadrant test and be wrongly returned as quadrant IV by the final line.
Plotting with a program
A plotting library does the counting and drawing for you, but you still have to supply the coordinates in the right order. This program plots five points, one in each quadrant and one at the origin.
import matplotlib.pyplot as plt
points = [(3, 2), (-4, 5), (-1, -6), (2, -3), (0, 0)]
xs = [p[0] for p in points]
ys = [p[1] for p in points]
fig, ax = plt.subplots()
ax.scatter(xs, ys)
for x, y in points:
ax.annotate(f"({x}, {y})", (x, y), textcoords="offset points", xytext=(5, 5))
ax.axhline(0, color="black")
ax.axvline(0, color="black")
ax.set_xlim(-8, 8)
ax.set_ylim(-8, 8)
ax.set_aspect("equal")
ax.grid(True)
plt.show()Several lines are worth understanding:
scatter(xs, ys)takes all the x-values first and then all the y-values. It does not take a list of pairs. This matches the way people mix up the order by hand, so check it every time.axhline(0)andaxvline(0)draw the x-axis and y-axis as black lines through the origin.set_xlimandset_ylimfix the visible range, which is the scale choice from the previous chapter.set_aspect("equal")gives both axes the same unit length. Without it, a square can be drawn as a rectangle, and distances and angles look wrong.
Common errors
| Error | What happens | How to avoid it |
|---|---|---|
| Swapping x and y | (2, 5) is plotted as (5, 2), a different point | Say "across, then up" while you work |
| Ignoring a negative sign | (-3, 4) is plotted in the upper right | Check the signs against the expected quadrant |
| Counting squares instead of reading the scale | A point is placed at the wrong value | Read the numbers printed on each axis |
| Counting the origin as step 1 | The point lands one unit short | Start counting from 0, so the first tick is 1 |
| Using different scales without noticing | Shapes look stretched | Compare the tick spacing on both axes |
| Plotting a zero coordinate off the axis | (0, 4) is drawn beside the y-axis | A zero means no movement in that direction |
Edge cases
- Points on an axis. A point with y = 0 lies on the x-axis, and a point with x = 0 lies on the y-axis. You move along only one axis. The origin (0, 0) is the one point where you do not move at all.
- Fractions and decimals. The point (1.5, -2.5) lies halfway between 1 and 2 on the x-axis, and halfway between -2 and -3 on the y-axis. Pick a scale that makes such positions easy to find.
- Large values. For (120, -45) you cannot use one tick per unit on a page. Choose a scale such as 10 units per tick, and expect the position of the point to be approximate.
- Different ranges on each axis. Points such as (2, 300) force different scales on the axes. Label each axis clearly, and remember that the picture will not preserve shape.
- Several points at once. When you plot many points, label each one or keep a list in order. Unlabeled dots cannot be told apart later.
Putting it together
Plotting and reading are a pair of inverse skills. To plot (x, y), move x horizontally and then y vertically. To read a point, project it onto each axis. In both cases the scale decides the value of each tick, the signs decide the direction and region, and the order of the pair decides which number goes with which axis.
Exercise
A graph has a tick every 10 units on the x-axis and a tick every 2 units on the y-axis. A point is 3 ticks to the left of the y-axis and 5 ticks below the x-axis. What are its coordinates, and in which quadrant does it lie?
Show answer
Each x tick is worth 10, so 3 ticks left gives x = -30. Each y tick is worth 2, so 5 ticks down gives y = -10. The point is (-30, -10). Both coordinates are negative, so it lies in quadrant III.
Exercise
Plot A(-2, 4), B(3, 4) and C(3, -1) and describe what you notice. What would the coordinates of a fourth point D be if A, B, C and D are to be the corners of a rectangle?
Show answer
A and B both have y = 4, so they lie on one horizontal line. B and C both have x = 3, so they lie on one vertical line. D must share x with A and y with C, so D = (-2, -1).
Exercise
The code plt.scatter([1, 4], [6, 2]) is meant to plot the points (1, 6) and (4, 2). Is the call correct? What would happen if you passed [(1, 6), (4, 2)] as the only argument?
Show answer
The call is correct. The first list holds the x-values and the second list holds the y-values, so the points are (1, 6) and (4, 2). Passing a single list of pairs does not work, because scatter expects the x-values and y-values as separate sequences. It would raise an error because the y-values are missing.