Finding the Equation of a Line from a Graph

When a question shows you a graph of a straight line and asks for its equation, you only need two numbers: the slope m and the y-intercept b. Then the answer is y = mx + b.

−4−224−4−224run = 6rise = 4(−3, −1)(3, 3)
This line passes through (−3, −1) and (3, 3) and crosses the y-axis at 1.

Step by step

  1. Choose two exact points. Look for places where the line passes exactly through the corner of a grid square. Points that are only roughly on the line give a roughly right answer.
  2. Count the run and the rise from the left point to the right point. In the graph above, the run is 6 and the rise is 4.
  3. Work out the slope. m = rise ÷ run = 4/6 = 2/3.
  4. Find the y-intercept where the line crosses the y-axis. Here it crosses at 1, so b = 1.
  5. Write the equation: y = ⅔x + 1.
  6. Check it with a point you didn’t use. At x = −3: ⅔ × (−3) + 1 = −2 + 1 = −1. The graph passes through (−3, −1). ✓

Open this line in Slope Finder →

When the y-intercept is between grid lines

Sometimes the line crosses the y-axis between two grid lines, so you can’t read b exactly. Calculate it instead.

Example

A line passes exactly through (1, 2) and (3, 5). The slope is (5 − 2) ÷ (3 − 1) = 3/2.

Substitute one point into y = mx + b: 2 = 3/2 × 1 + b, so b = 1/2.

The equation is y = 3/2 x + ½. On the graph, the line crosses the y-axis halfway between 0 and 1, which matches.

When the axes don’t count in 1s

Always read the numbers on the axes rather than counting squares. If each square on the y-axis is worth 5 and each square on the x-axis is worth 1, a line that goes up 3 squares and across 2 squares has a rise of 15 and a run of 2. Its slope is 15/2, not 3/2.

Using a photo of your graph

If your graph is on paper or in a textbook, you can photograph it and let the Slope Finder read it. You mark two numbered ticks on each axis, then click two points on the line, and it shows the slope and equation with the working. The photo guide explains each step.

Common mistakes

  • Counting grid lines instead of squares, which makes the run or rise one too big.
  • Getting the sign of the slope wrong. A line going down from left to right must have a negative slope.
  • Reading b from the x-axis instead of the y-axis.