Skip to content
Graph Linear Equations in Two Variables

Graph Linear Equations in Two Variables

By the end of this section, you will be able to: recognize the relationship between the solutions of an equation and its graph, graph a linear equation by plotting points, and graph vertical and horizontal lines.

Recognize the relationship between the solutions of an equation and its graph

In the previous section, we found several solutions to the equation 3x+2y=63x + 2y = 6. They are listed in the table below. So the ordered pairs (0,3)(0, 3), (2,0)(2, 0), and (1,32)\left(1, \tfrac{3}{2}\right) are some solutions to the equation 3x+2y=63x + 2y = 6. We can plot these solutions in the rectangular coordinate system, as shown below.

3x+2y=63x + 2y = 6
xxyy(x,y)(x, y)
0033(0,3)(0, 3)
2200(2,0)(2, 0)
1132\tfrac{3}{2}(1,32)\left(1, \tfrac{3}{2}\right)
xy(0, 3)(1, 3/2)(2, 0)

Notice how the points line up perfectly? We connect the points with a line to get the graph of the equation 3x+2y=63x + 2y = 6, shown below. Notice the arrows on the ends of the line — they indicate the line continues in both directions.

xy3x + 2y = 6

Every point on the line is a solution of the equation. Also, every solution of this equation is a point on this line. Points not on the line are not solutions.

Notice that the point (2,6)(-2, 6) is on the line shown below. If you substitute x=2x = -2 and y=6y = 6 into the equation, you find that it is a solution to the equation:

3x+2y=63x + 2y = 6

3(2)+2(6)=63(-2) + 2(6) = 6

6+12=6-6 + 12 = 6

6=66 = 6 \checkmark

So the point (2,6)(-2, 6) is a solution to the equation 3x+2y=63x + 2y = 6. What about (4,1)(4, 1)?

3x+2y=63x + 2y = 6

3(4)+2(1)=63(4) + 2(1) = 6

12+2=?612 + 2 \stackrel{?}{=} 6

14614 \neq 6

So (4,1)(4, 1) is not a solution to the equation 3x+2y=63x + 2y = 6. Therefore, the point (4,1)(4, 1) is not on the line. This is an example of the saying, “A picture is worth a thousand words.” The line shows you all the solutions to the equation. Every point on the line is a solution of the equation, and every solution of this equation is a point on this line. This line is called the graph of the equation 3x+2y=63x + 2y = 6.

Graph of a linear equation. The graph of a linear equation Ax+By=CAx + By = C is a line.

  • Every point on the line is a solution of the equation.
  • Every solution of this equation is a point on this line.

Example. The graph of y=2x3y = 2x - 3 is shown below.

xyy = 2x − 3

For each ordered pair, decide: (a) is the ordered pair a solution to the equation? (b) is the point on the line? We’ll check A(0,3)A(0, -3), B(3,3)B(3, 3), C(2,3)C(2, -3), and D(1,5)D(-1, -5).

(a) Substitute the xx- and yy-values into the equation y=2x3y = 2x - 3 to check whether each ordered pair is a solution.

A:(0,3)3=?2(0)33=3  B:(3,3)3=?2(3)33=3  C:(2,3)3=?2(2)331D:(1,5)5=?2(1)35=5   \begin{array}{lrcl} A: (0, -3) & -3 &\stackrel{?}{=}& 2(0) - 3 \\[4pt] & -3 &=& -3 \; \checkmark \\[4pt] B: (3, 3) & 3 &\stackrel{?}{=}& 2(3) - 3 \\[4pt] & 3 &=& 3 \; \checkmark \\[4pt] C: (2, -3) & -3 &\stackrel{?}{=}& 2(2) - 3 \\[4pt] & -3 &\neq& 1 \\[4pt] D: (-1, -5) & -5 &\stackrel{?}{=}& 2(-1) - 3 \\[4pt] & -5 &=& -5 \; \checkmark \end{array}

So (0,3)(0, -3), (3,3)(3, 3), and (1,5)(-1, -5) are solutions, while (2,3)(2, -3) is not a solution.

(b) Plotting the four points confirms it: (0,3)(0, -3), (3,3)(3, 3), and (1,5)(-1, -5) fall on the line y=2x3y = 2x - 3, but (2,3)(2, -3) does not. The points that are solutions to y=2x3y = 2x - 3 are on the line, and the point that is not a solution is not on the line.

The line y=3x1y = 3x - 1 passes through the point (2,5)(2, 5). Is (2,5)(2, 5) a solution to the equation? Enter the value of 3x13x - 1 when x=2x = 2.

For the equation y=3x1y = 3x - 1, substitute x=1x = -1 to find the y-coordinate of the point on the line.

Graph a linear equation by plotting points

There are several methods that can be used to graph a linear equation. The method we used to graph 3x+2y=63x + 2y = 6 is called plotting points, or the Point-Plotting Method.

How To: Graph an equation by plotting points. Graph the equation y=2x+1y = 2x + 1 by plotting points.

Step 1. Find three points whose coordinates are solutions to the equation. You can choose any values for xx or yy. In this case, since yy is isolated on the left side of the equation, it is easier to choose values for xx.

x=0:y=2(0)+1=1x=1:y=2(1)+1=3x=2:y=2(2)+1=3x = 0: \quad y = 2(0) + 1 = 1 \qquad\qquad x = 1: \quad y = 2(1) + 1 = 3 \qquad\qquad x = -2: \quad y = 2(-2) + 1 = -3

Organize the solutions in a table:

y=2x+1y = 2x + 1
xxyy(x,y)(x, y)
0011(0,1)(0, 1)
1133(1,3)(1, 3)
2-23-3(2,3)(-2, -3)

Step 2. Plot the points in a rectangular coordinate system. Check that the points line up. If they do not, carefully check your work.

Step 3. Draw the line through the three points. Extend the line to fill the grid and put arrows on both ends of the line — this line is the graph of y=2x+1y = 2x + 1.

xy(−2, −3)(0, 1)(1, 3)

It is true that it only takes two points to determine a line, but it is a good habit to use three points. If you only plot two points and one of them is incorrect, you can still draw a line, but it will be the wrong line. If you use three points and one is incorrect, the points will not line up — this tells you something is wrong and you need to check your work.

Graph y=3xy = -3x by plotting points. Let x=0x = 0. Find y.

For the equation y=3xy = -3x, let x=2x = -2. Find y.

When an equation includes a fraction as the coefficient of xx, we can still substitute any numbers for xx. But the math is easier if we make “good” choices for the values of xx — choosing multiples of the denominator avoids fraction answers, which are hard to graph precisely.

Example. Graph the equation y=12x+3y = \tfrac{1}{2}x + 3.

Since this equation has the fraction 12\tfrac{1}{2} as a coefficient of xx, we choose values of xx carefully. We use zero as one choice and multiples of 22 for the other choices, so that 12x\tfrac{1}{2}x comes out even each time.

x=0:y=12(0)+3=3x=2:y=12(2)+3=4x=4:y=12(4)+3=5x = 0: \quad y = \tfrac{1}{2}(0) + 3 = 3 \qquad x = 2: \quad y = \tfrac{1}{2}(2) + 3 = 4 \qquad x = 4: \quad y = \tfrac{1}{2}(4) + 3 = 5
y=12x+3y = \tfrac{1}{2}x + 3
xxyy(x,y)(x, y)
0033(0,3)(0, 3)
2244(2,4)(2, 4)
4455(4,5)(4, 5)

Plotting the points, checking that they line up, and drawing the line gives the graph of y=12x+3y = \tfrac{1}{2}x + 3.

Graph y=13x1y = \tfrac{1}{3}x - 1 by plotting points. To avoid fractions, let x=3x = 3. Find y.

For the equation y=13x1y = \tfrac{1}{3}x - 1, let x=6x = 6. Find y.

So far, all the equations we graphed had yy given in terms of xx. Now we’ll graph an equation with xx and yy on the same side, such as 2x+y=32x + y = 3. When an equation is in this form, it is often easier to find the intercepts than to pick three arbitrary values — first solve the equation for yy so it is easier to find points, or find one point by letting x=0x = 0 and another by letting y=0y = 0.

If we solve 2x+y=32x + y = 3 for yy, we get y=2x+3y = -2x + 3. The solutions for x=0x = 0, x=1x = 1, and x=1x = -1 are shown below.

2x+y=32x + y = 3
xxyy(x,y)(x, y)
0033(0,3)(0, 3)
1111(1,1)(1, 1)
1-155(1,5)(-1, 5)

Example. Graph the equation 2x3y=62x - 3y = 6.

Since both xx and yy are on the same side, it is not that easy to solve for yy in one step, so we leave the equation in standard form and find a first point by letting x=0x = 0, a second point by letting y=0y = 0, and a third point by choosing some other value.

x=0:2(0)3y=6    y=2y=0:2x3(0)=6    x=3x = 0: \quad 2(0) - 3y = 6 \implies y = -2 \qquad\qquad y = 0: \quad 2x - 3(0) = 6 \implies x = 3

We need a third point. We’ll let x=6x = 6:

2(6)3y=6    123y=6    3y=6    y=22(6) - 3y = 6 \implies 12 - 3y = 6 \implies -3y = -6 \implies y = 2
2x3y=62x - 3y = 6
xxyy(x,y)(x, y)
002-2(0,2)(0, -2)
3300(3,0)(3, 0)
6622(6,2)(6, 2)

Plot the points, check that they line up, and draw the line. If you can choose any three points to graph a line, how will you know if your graph matches the one shown in the answer key? If the points where the graphs cross the xx- and yy-axes are the same, the graphs match!

Graph the equation 2x - 3y = 6 (a different way): let y=0y = 0 and solve for x.

For the equation 2x3y=62x - 3y = 6, let x=0x = 0 and solve for y.

Graph vertical and horizontal lines

Can we graph an equation with only one variable — just xx and no yy, or just yy without an xx? How will we make a table of values to get the points to plot?

Let’s consider the equation x=3x = -3. This equation has only one variable, xx. The equation says that xx is always equal to 3-3, so its value does not depend on yy. To make a table of values, we write 3-3 in for all the xx-values, then choose any values for yy — we’ll use 11, 22, and 33.

x=3x = -3
xxyy(x,y)(x, y)
3-311(3,1)(-3, 1)
3-322(3,2)(-3, 2)
3-333(3,3)(-3, 3)

Plotting these points and connecting them with a straight line gives a vertical line.

xy(−3, 1)(−3, 2)(−3, 3)
Vertical line. A vertical line is the graph of an equation of the form x=ax = a. The line passes through the xx-axis at (a,0)(a, 0).

Example. Graph the equation x=2x = 2.

The equation has only one variable, xx, and xx is always equal to 22. We create a table where xx is always 22, then put in any values for yy. The graph is a vertical line passing through the xx-axis at 22.

Graph the equation x=5x = 5. What is the x-coordinate of every point on this line?

Graph the equation x=2x = -2. At what x-coordinate does this vertical line cross the x-axis?

What if the equation has yy but no xx? Let’s graph the equation y=4y = 4. This time the yy-value is a constant, so in this equation yy does not depend on xx. Fill in 44 for all the yy’s in the table below and choose any values for xx — we’ll use 00, 22, and 44.

y=4y = 4
xxyy(x,y)(x, y)
0044(0,4)(0, 4)
2244(2,4)(2, 4)
4444(4,4)(4, 4)

The graph is a horizontal line passing through the yy-axis at 44.

xy(0, 4)(2, 4)(4, 4)
Horizontal line. A horizontal line is the graph of an equation of the form y=by = b. The line passes through the yy-axis at (0,b)(0, b).

Example. Graph the equation y=1y = -1.

The equation y=1y = -1 has only one variable, yy. The value of yy is constant. All the ordered pairs in its table have the same yy-coordinate. The graph is a horizontal line passing through the yy-axis at 1-1.

Graph the equation y=4y = -4. What is the y-coordinate of every point on this line?

Graph the equation y=3y = 3. At what point does this horizontal line cross the y-axis?

The equations for vertical and horizontal lines look very similar to equations like y=4xy = 4x. What is the difference between the equations y=4xy = 4x and y=4y = 4?

The equation y=4xy = 4x has both xx and yy. The value of yy depends on the value of xx, so the yy-coordinate changes according to the value of xx. The equation y=4y = 4 has only one variable. The value of yy is constant — the yy-coordinate is always 44. It does not depend on the value of xx.

y=4xy = 4xy=4y = 4
xxyy(x,y)(x, y)xxyy(x,y)(x, y)
0000(0,0)(0, 0)0044(0,4)(0, 4)
1144(1,4)(1, 4)1144(1,4)(1, 4)
2288(2,8)(2, 8)2244(2,4)(2, 4)

Graphing both equations in the same rectangular coordinate system shows the difference clearly: y=4xy = 4x gives a slanted line through the origin, while y=4y = 4 gives a horizontal line.

xyy = 4xy = 4

Compare y=3xy = -3x and y=3y = -3. When x=2x = 2, what is y for the equation y=3xy = -3x?

For the equation y = -3 (not y = -3x), what is y when x=2x = 2?

Key terms

graph of a linear equation — the line consisting of all the points that are solutions of the equation Ax+By=CAx + By = C; every point on the line is a solution of the equation, and every solution of the equation is a point on the line. plotting points (Point-Plotting Method) — a method for graphing a linear equation by finding several ordered-pair solutions, plotting them, and drawing the line through them. vertical line — the graph of an equation of the form x=ax = a; a straight up-and-down line that crosses the xx-axis at (a,0)(a, 0). horizontal line — the graph of an equation of the form y=by = b; a straight side-to-side line that crosses the yy-axis at (0,b)(0, b).


This section is adapted from Elementary Algebra 2e, Section 4.2: Graph Linear Equations in Two Variables by Lynn Marecek, MaryAnne Anthony-Smith, and Andrea Honeycutt Mathis, © OpenStax, licensed under CC BY-NC-SA 4.0. Access the original for free at openstax.org. Changes: recreated the coordinate-plane graphs (points, lines, vertical and horizontal lines, and the paired y=4xy = 4x vs. y=4y = 4 comparison) as accessible inline SVGs and the solution tables as markdown tables; omitted the Be Prepared quiz, Self Check checklist, and end-of-section exercises; and converted the practice problems (“Try Its”) into interactive exercises with instant feedback.