Chapter 6 · Proportional relationships, lines, and slope

Graphing Horizontal and Vertical Lines

Learn why an equation that fixes one coordinate graphs as a horizontal or vertical line, and how to plot each kind from exact points.

12 min read

You already know how to graph a line from a table of values. But what happens when an equation names only one variable, such as y=3y = 3 or x=−2x = -2? The same skill still works, and it leads to two special kinds of lines.

First, recall what a graph is. Each point on a coordinate plane is named by an ordered pair (x,y)(x, y). The x-coordinate tells you how far the point is to the right (positive) or left (negative) of the vertical y-axis. The y-coordinate tells you how far it is above (positive) or below (negative) the horizontal x-axis. In this lesson, xx and yy are plain numbers, not measurements, so distances are counted in grid units. The graph of an equation is the set of all points whose coordinates make the equation true.

So what does y=3y = 3 ask of a point? Only that its y-coordinate is 33. The equation never mentions xx, so xx can be any real number, which means any number on the number line. The table below shows four choices.

Table of values for y = 3
x (you choose)y (always 3)Point (x, y)
−4-4
33
(−4,3)(-4, 3)
00
33
(0,3)(0, 3)
22
33
(2,3)(2, 3)
44
33
(4,3)(4, 3)

The figure below plots the four points from the table. Its horizontal axis is the x-axis and its vertical axis is the y-axis. Each axis runs from −6-6 to 66, and the grid lines are 11 unit apart. Line A is the straight line through all four points.

Every point on Line A has the same y-coordinate, 33. A line like this is called a horizontal line. It runs left and right, in the same direction as the x-axis, and it stays exactly 33 units above it. It crosses the y-axis at (0,3)(0, 3). It never touches the x-axis, because every point on the x-axis has y-coordinate 00, not 33.

The figure shows only part of the line. Points such as (100,3)(100, 3) and (−2.5,3)(-2.5, 3) are on it too, because each has y-coordinate 33. That is the test to trust: read the coordinates, not how the picture looks.

Coordinate grid from x -6 to 6 and y -6 to 6, with a grid step of 1, showing 5 plotted elements. Details: line 0 x plus 1 y equals 3, named Line A; point at (-4, 3), named (-4, 3); point at (0, 3), named (0, 3); point at (2, 3), named (2, 3); point at (4, 3), named (4, 3).
Line A is the graph of y=3y = 3. Each labeled point from the table has y-coordinate 33.

Worked example

Fixing x instead of y

Graph the equation x=−2x = -2 on a coordinate plane. As before, the x-axis is horizontal, the y-axis is vertical, each axis runs from −6-6 to 66, and the grid lines are 11 unit apart.

  1. Read what the equation asks. A point is on the graph exactly when its x-coordinate is -2. The equation never mentions y, so y can be any real number.

    x=−2,y is any real numberx = -2, \quad y \text{ is any real number}
  2. List values as you would in a table. This time you choose the y-values, because y is the coordinate left free. Choosing -3, 0 and 4 gives three points, each with x-coordinate -2.

    (−2,−3),(−2,0),(−2,4)(-2, -3), \quad (-2, 0), \quad (-2, 4)
  3. Plot the three points. Each one is 2 units to the left of the y-axis: the negative sign of -2 tells you the direction, and the distance is 2. Only their up-and-down positions differ: 3 units below the x-axis, on the x-axis, and 4 units above it.

  4. Draw the straight line through the three points. It is Line A in the figure below. Every point on it has the same x-coordinate, -2. A line like this is called a vertical line. It runs up and down, in the same direction as the y-axis, and it crosses the x-axis at (-2, 0).

  5. Check with coordinates, not by eye. The point (-2, 5.5) has x-coordinate -2, so it is on the graph. The point (3, -2) has -2 as its y-coordinate, but its x-coordinate is 3, so it is not on the graph.

    At (−2,5.5): x=−2At (3,−2): x=3≠−2\text{At } (-2, 5.5):\ x = -2 \qquad \text{At } (3, -2):\ x = 3 \neq -2

Answer

The graph of x=−2x = -2 is the vertical line through (−2,0)(-2, 0). It stays exactly 22 units to the left of the y-axis.

Coordinate grid from x -6 to 6 and y -6 to 6, with a grid step of 1, showing 5 plotted elements. Details: line 1 x plus 0 y equals -2, named Line A; point at (-2, -3), named (-2, -3); point at (-2, 0), named (-2, 0); point at (-2, 4), named (-2, 4); point at (3, -2), named (3, -2).
Line A is the graph of x=−2x = -2. The three points on it have x-coordinate −2-2. The point (3,−2)(3, -2) is not on Line A.

Key concept

One coordinate stays fixed

Let kk and hh stand for fixed real numbers.

  • The graph of y=ky = k is a horizontal line. Every point on it has y-coordinate kk, and xx can be any real number. It crosses the y-axis at (0,k)(0, k).
  • The graph of x=hx = h is a vertical line. Every point on it has x-coordinate hh, and yy can be any real number. It crosses the x-axis at (h,0)(h, 0).

The axes are special cases: the x-axis is the line y=0y = 0, and the y-axis is the line x=0x = 0.

To graph either kind, plot two or more different points that have the fixed coordinate, then draw the straight line through them.

y=k (horizontal)x=h (vertical)y = k \ \text{(horizontal)} \qquad x = h \ \text{(vertical)}

Worked example

Two lines on one plane

Graph y=−4y = -4 and x=3x = 3 on one coordinate plane. As before, the x-axis is horizontal, the y-axis is vertical, each axis runs from −6-6 to 66, and the grid lines are 11 unit apart. Which point lies on both lines?

  1. Name the coordinate each equation fixes. In y = -4 the y-coordinate is fixed, so the graph is a horizontal line. In x = 3 the x-coordinate is fixed, so the graph is a vertical line.

    y=−4 (horizontal)x=3 (vertical)y = -4 \ \text{(horizontal)} \qquad x = 3 \ \text{(vertical)}
  2. Plot two points for y = -4. Use x = 0 for the point on the y-axis, then choose x = -3. Keep y at -4 both times, so both points are 4 units below the x-axis. The line through them is Line A in the figure below.

    (0,−4),(−3,−4)(0, -4), \quad (-3, -4)
  3. Plot two points for x = 3. Use y = 0 for the point on the x-axis, then choose y = 2. Keep x at 3 both times, so both points are 3 units to the right of the y-axis. The line through them is Line B.

    (3,0),(3,2)(3, 0), \quad (3, 2)
  4. Find the point on both lines. It must make both equations true, so its x-coordinate is 3 and its y-coordinate is -4. Write the x-coordinate first.

    (x,y)=(3,−4)(x, y) = (3, -4)
  5. Check the order of the coordinates. The point (-4, 3) has x-coordinate -4, so it fails x = 3. The point (3, -4) has x-coordinate 3 and y-coordinate -4, so it passes both tests.

    x=3andy=−4x = 3 \quad \text{and} \quad y = -4

Answer

The graph of y=−4y = -4 is the horizontal line 44 units below the x-axis. The graph of x=3x = 3 is the vertical line 33 units to the right of the y-axis. The point (3,−4)(3, -4) is the only point on both lines.

Coordinate grid from x -6 to 6 and y -6 to 6, with a grid step of 1, showing 7 plotted elements. Details: line 0 x plus 1 y equals -4, named Line A; line 1 x plus 0 y equals 3, named Line B; point at (0, -4), named (0, -4); point at (-3, -4), named (-3, -4); point at (3, 0), named (3, 0); point at (3, 2), named (3, 2); point at (3, -4), named (3, -4).
Line A is the graph of y=−4y = -4 and Line B is the graph of x=3x = 3. They meet at (3,−4)(3, -4).

One more fact separates these two kinds of lines: slope. Slope measures how steep a line is. Go from one point on the line to a different point on it, then divide the change in yy by the change in xx. You can do that division only when the change in xx is not 00. Try it on the two lines in the figure above.

  • Line A, horizontal. From (−3,−4)(-3, -4) to (0,−4)(0, -4), the change in yy is −4−(−4)=−4+4=0-4 - (-4) = -4 + 4 = 0 and the change in xx is 0−(−3)=0+3=30 - (-3) = 0 + 3 = 3. The slope is 0÷3=00 \div 3 = 0. Every horizontal line has slope 00, because two different points on it have equal y-coordinates and unequal x-coordinates.
  • Line B, vertical. From (3,0)(3, 0) to (3,2)(3, 2), the change in yy is 2−0=22 - 0 = 2, but the change in xx is 3−3=03 - 3 = 0. You can't divide 22 by 00, so the slope is undefined. The same happens on every vertical line, because all of its points share one x-coordinate. Undefined does not mean 00.

Takeaway. An equation of the form y=ky = k or x=hx = h fixes one coordinate and leaves the other free. The graph of y=ky = k is the horizontal line through (0,k)(0, k), and its slope is 00. The graph of x=hx = h is the vertical line through (h,0)(h, 0). Its slope is undefined, and it is not a function of xx. If you're unsure which is which, test a point's coordinates in the equation.

Next, you'll meet equations that keep both variables on one side, such as 2x+3y=62x + 3y = 6. That layout is called standard form. You'll learn to rewrite it with yy alone on one side, called slope-intercept form, and then graph it.