Free original lessons

Graphing Horizontal and Vertical Lines: x = a and y = b

Learn to plot special-case lines x = constant and y = constant on coordinate axes, label them, and explain why horizontal lines have slope 0 while vertical lines have undefined slope.

Free lesson
Four exercises
Worked answers

Algebra and Function Practice

Most lines on a coordinate grid slant. Two special families do not: lines written x = a are vertical, and lines written y = b are horizontal. In this lesson you will plot both types from their equations, label them correctly, and use a simple slope check to confirm each result. The convention used here is that every grid has equal spacing on both axes, the origin is marked, and each axis is labeled with its variable. All numerical values in examples are hypothetical teaching values chosen for easy counting.

Practice materials: Printable downloads are not available for this lesson yet. Use the instructions and four exercises below.

Reading the equation before plotting

An equation such as x = 3 contains only one variable. It says that every point on the line has an x-coordinate of 3, while the y-coordinate may be any number. Because x is fixed and y varies, the points stack straight up and down: the result is a vertical line. Similarly, y = -2 fixes the y-coordinate at -2 while x varies freely, producing a horizontal line.

A quick test: if the equation names x only, the line is vertical; if it names y only, the line is horizontal. This test works for positive, negative, and zero constants. The line x = 0 is the y-axis itself, and y = 0 is the x-axis.

  1. Identify which variable appears in the equation.
  2. If x = a, plan a vertical line through a on the x-axis.
  3. If y = b, plan a horizontal line through b on the y-axis.
  4. Choose at least three test points that satisfy the equation.
  5. Plot the points, connect them with a straight edge, and label the line with its equation.

Plotting a vertical line step by step

To plot x = 4, start at 4 on the x-axis. Any point with x-coordinate 4 lies on the line, so (4, 0), (4, 2), and (4, -3) are all valid test points. Plot them, then draw a straight line through them parallel to the y-axis. Label the line x = 4 near its top or bottom end so the label does not cover a plotted point.

A common slip is to move along the y-axis instead of the x-axis when locating the constant. Say the equation aloud: x equals four means every point is four units right of the y-axis. Checking a plotted point against the equation catches this error immediately.

  1. Locate the constant on the correct axis.
  2. Write three test points with that constant in the matching coordinate.
  3. Plot the three points and align a straight edge.
  4. Draw the line and add the equation as a label.
  5. Verify one point by substituting its coordinates into the equation.

Plotting a horizontal line step by step

To plot y = -2, start at -2 on the y-axis. Valid test points include (0, -2), (3, -2), and (-4, -2). Plot them and draw a line parallel to the x-axis. The label y = -2 should sit clearly beside the line, not on top of a point.

Horizontal and vertical lines are mirror cases: in y = b the y-coordinate is fixed and x varies, so the line runs left to right. Reading the equation slowly and naming the fixed variable prevents mixing up the two families.

  1. Locate the constant on the y-axis.
  2. Write three test points sharing that y-coordinate.
  3. Plot the points and align a straight edge horizontally.
  4. Draw the line and label it y = b.
  5. Substitute one point into the equation to confirm.

Why the slopes differ

Slope measures vertical change divided by horizontal change between two points. On a horizontal line such as y = 5, moving from (1, 5) to (4, 5) changes y by 0 while x changes by 3, so the slope is 0 divided by 3, which equals 0. On a vertical line such as x = 2, moving from (2, 1) to (2, 6) changes y by 5 while x changes by 0. Division by zero is undefined, so a vertical line has undefined slope, not zero slope.

This distinction matters when matching equations to graphs. A slope of 0 always signals a horizontal line; an undefined slope always signals a vertical line. Neither type can be written in the usual y = mx + b form with a finite m, which is why the special forms x = a and y = b are used.

  1. Pick two points on the line.
  2. Compute the change in y and the change in x.
  3. Divide the change in y by the change in x.
  4. If the result is 0, the line is horizontal; if the denominator is 0, the slope is undefined and the line is vertical.

Worked example

Graph the line x = -3 on a coordinate grid with equal spacing on both axes, then state its slope.

Worked answer

The graph is a vertical line passing through -3 on the x-axis, labeled x = -3. Its slope is undefined.

Why: The equation fixes x at -3 while y may be any value. Test points include (-3, 0), (-3, 2), and (-3, -4). Plotting and connecting them gives a line parallel to the y-axis. Between (-3, 0) and (-3, 2), the change in y is 2 and the change in x is 0, so slope is 2 divided by 0, which is undefined.

Check: Substitute each plotted point into x = -3; all should satisfy it. Confirm the line is parallel to the y-axis and that the label reads x = -3.

Four practice exercises

Exercise 1

Graph y = 4 on a grid with equal spacing and state its slope.

Show answer and check

A horizontal line through 4 on the y-axis, labeled y = 4, with slope 0.

Why: The equation fixes y at 4 while x varies. Test points include (0, 4), (2, 4), and (-3, 4). Connecting them gives a line parallel to the x-axis. Between (0, 4) and (2, 4), the change in y is 0 and the change in x is 2, so slope is 0 divided by 2, which equals 0.

Check: Substitute each plotted point into y = 4; all should satisfy it. Confirm the line is parallel to the x-axis and the label is complete.

Exercise 2

Graph x = 2 on a grid with equal spacing and state its slope.

Show answer and check

A vertical line through 2 on the x-axis, labeled x = 2, with undefined slope.

Why: The equation fixes x at 2 while y varies. Test points include (2, 0), (2, 3), and (2, -1). Connecting them gives a line parallel to the y-axis. Between (2, 0) and (2, 3), the change in y is 3 and the change in x is 0, so slope is 3 divided by 0, which is undefined.

Check: Substitute each plotted point into x = 2; all should satisfy it. Confirm the line is parallel to the y-axis and the slope is stated as undefined, not 0.

Exercise 3

A classmate graphs y = -1 as a vertical line through -1 on the x-axis. Identify the error and describe the correct graph.

Show answer and check

The classmate fixed the wrong variable. The correct graph is a horizontal line through -1 on the y-axis, labeled y = -1, with slope 0.

Why: In y = -1 the y-coordinate is fixed at -1 and x varies, so the line runs left to right. Valid test points include (0, -1), (2, -1), and (-3, -1). A vertical line through -1 on the x-axis would be x = -1, a different equation.

Check: Read the equation and name the fixed variable. Plot three test points and confirm they share a y-coordinate of -1 and form a horizontal line.

Exercise 4

Without graphing, decide whether each line is horizontal or vertical and give its slope: x = 5, y = 0, y = -3, x = 0.

Show answer and check

x = 5 is vertical with undefined slope; y = 0 is horizontal with slope 0; y = -3 is horizontal with slope 0; x = 0 is vertical with undefined slope.

Why: An equation naming only x fixes the x-coordinate, so the line is vertical and its slope is undefined. An equation naming only y fixes the y-coordinate, so the line is horizontal and its slope is 0. The constants 5, 0, -3, and 0 do not change the line type.

Check: For each equation, substitute two sample points and compute the slope. A zero numerator gives slope 0; a zero denominator gives undefined slope.

Common mistakes

Self-check rubric

Questions and answers

How can I tell from an equation whether the line is horizontal or vertical?

Look at which variable appears. An equation naming only x, such as x = -1, is vertical. An equation naming only y, such as y = 6, is horizontal.

Is x = 0 the same as the y-axis?

Yes. Every point with x-coordinate 0 lies on the y-axis, so the graph of x = 0 is the y-axis. Likewise y = 0 is the x-axis.

Why is the slope of a vertical line undefined rather than zero?

Slope is the change in y divided by the change in x. On a vertical line the change in x is 0, and division by zero has no defined value.

Do I need many points to draw these lines?

Two points determine a line, but plotting three points is a useful check. If the three points do not line up, one of them is probably misplaced.

Worksheet preview

Full printable sheet preview

Fit-to-screen preview. Download the PDF to print at actual size.