Uni-Sine
MathematicsGraphs

Graphing linear equations (straight-line graphs)

Graphing linear equations means drawing the straight line that every solution of the equation lies on. The quickest way is to write the equation as y = mx + b: plot the y-intercept b on the y-axis, then use the slope m, the rise over the run, to step to a second point, and join them with a ruler. In the UK the same equation is written y = mx + c, and the slope is called the gradient.

What makes an equation linear?

A linear equation has x and y only to the power 1: no x², no √x, no x in a denominator, and x and y are never multiplied together. Its graph is always a straight line, because y changes by the same amount every time x goes up by 1. That fixed rate of change is the slope.

FormEquationWhat you can read off
Slope-intercepty = mx + bSlope m and y-intercept (0, b)
Point-slopey − y₁ = m(x − x₁)Slope m and one point (x₁, y₁)
StandardAx + By = CBoth intercepts, quickly

All three describe the same lines, and you can rearrange any one into another. The point-slope form and standard form guides go into each in more depth.

Slope and intercepts

The slope measures steepness: how far the line rises for each step to the right. Between two points (x₁, y₁) and (x₂, y₂):

m=\frac{y_2-y_1}{x_2-x_1}=\frac{\text{rise}}{\text{run}}
  • A positive slope goes up from left to right; a negative slope goes down.
  • A bigger number, positive or negative, means a steeper line.
  • The y-intercept is where the line crosses the y-axis, so x = 0 there.
  • The x-intercept is where it crosses the x-axis, so y = 0 there.

Try reading a slope from a graph, then press Mark to check it in the course:

Compute the slope through two plotted points, typed as a fraction or decimal.

Press Mark to have your answer marked in the Graphing Functions course.

Method 1: graph from the slope and y-intercept

Use this when the equation is already y = mx + b.

Example 1: graph y = 2x − 3

  1. The y-intercept is b = −3, so plot (0, −3).
  2. The slope is m = 2, which is 2/1: up 2 for every 1 across. From (0, −3) go right 1 and up 2 to (1, −1), then again to (2, 1).
  3. Draw a straight line through the points and extend it across the grid.
y = 2 x-3
-2-1.5-1-0.50.511.522.533.54-8-6-4-2246y-intercept (0, −3)x-intercept (1.5, 0)(2, 1)
Drag to pan, scroll to zoom. x from -2 to 4, y from -9.4 to 7.4.

Here x and y are the usual coordinates. Setting y = 0 gives 2x − 3 = 0, so the line crosses the x-axis at x = 1.5, which matches the graph. A fractional slope works the same way: for m = −3/4, go right 4 and down 3.

Method 2: graph from a table of values

This works for any form and is a good check. Pick three x values, work out y for each, plot the points and join them. Three points matter: if they do not line up, you have made a mistake.

x−1012
y = 2x − 3−5−3−11

Method 3: graph from the intercepts

Use this for standard form, Ax + By = C, because each intercept takes one step.

Example 2: graph 3x + 4y = 12

  1. Put x = 0: 4y = 12, so y = 3. Plot (0, 3).
  2. Put y = 0: 3x = 12, so x = 4. Plot (4, 0).
  3. Join the two points. The slope is −3/4: down 3 for every 4 across.
y = -0.75 x+3
-2-1123456-2-112345(0, 3)(4, 0)
Drag to pan, scroll to zoom. x from -2 to 6, y from -2.7 to 5.7.

Rearranged for y, the equation is y = −0.75x + 3, which is the line drawn here, with x and y the usual coordinates.

Finding the equation from two points

Example 3: the line through (−1, 5) and (3, −3)

First the slope:

m=\frac{-3-5}{3-(-1)}=\frac{-8}{4}=-2

Then put one point into point-slope form and tidy up: y − 5 = −2(x + 1), so y − 5 = −2x − 2, and y = −2x + 3. Check with the other point: −2 × 3 + 3 = −3. It works. The slope calculator guide shows how to check this kind of question with a tool.

Special lines

  • Horizontal lines have the form y = k, such as y = 4. The slope is 0.
  • Vertical lines have the form x = k, such as x = −2. The slope is undefined, because the run is 0. A vertical line is not a function.
  • Parallel lines have equal slopes, such as y = 2x + 1 and y = 2x − 5.
  • Perpendicular lines have slopes that multiply to −1, such as 2 and −1/2. See perpendicular lines for more.

Common mistakes

  • Swapping rise and run. The slope is the change in y over the change in x, not the other way round.
  • Losing the minus sign. In y = −2x + 3 the slope is −2, so the line falls from left to right.
  • Reading b from standard form. In 3x + 4y = 12 the y-intercept is 3, not 12. Rearrange first or put x = 0.
  • Mixing the order of the points. If you take y₂ from the second point, take x₂ from the same point.

Common questions

How do you graph a linear equation?
Write it as y = mx + b. Plot the y-intercept (0, b), use the slope to step right and up or down to a second point, then draw a straight line through both. For standard form, plotting the two intercepts is often quicker.
What is the difference between y = mx + b and y = mx + c?
Nothing but the letter. US textbooks use b for the y-intercept and UK ones use c. In both, m is the slope, or gradient.
How do you find the slope of a line?
Pick two points on it and divide the change in y by the change in x: m = (y₂ − y₁)/(x₂ − x₁). On a graph, count the rise and the run between two points.
How do you know if an equation is linear?
x and y appear only to the first power, are not multiplied together and are not inside roots or denominators. y = 3x − 1 and 2x + 5y = 10 are linear; y = x² and y = 1/x are not.
What does the slope of a line tell you?
How much y changes when x goes up by 1. In a real situation it is a rate, such as cost per item or kilometres per hour, and the y-intercept is the starting value.
How many points do you need to graph a line?
Two points fix a straight line, but plotting a third is a good check, since all three must lie on one line.

Revision cards

Say the answer first, then flip the card to check it.

Where to go next

  • Solve it

    Linear Graph

    Plot and analyse linear functions

    Open the tool
  • Learn it

    Graphing Functions

    Graphing made easier: the patterns in numbers and functions used across STEM

    Start the course
  • Test it

    Pre-Algebra & Algebra 1

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · GraphsLinear graph calculator: plot y = mx + b, find interceptsFree linear graph calculator: plot y = mx + b, change the slope and intercept, and read where the line crosses each axis, with practice questions.