Linear Graph Generator

Plot y = mx + b lines and see where they meet, find the line through two points, or fit a regression line to X,Y data. Export a PNG, SVG or Excel file.

  • Runs in your browser
  • Free
  • No sign-up
Presets:
Line 1
Line 2

Where the lines meet

  • Line 1 and Line 2:(1, 3)
Graph window
Line 1: y = 2x + 1Line 2: y = -x + 4-6-4-202468-6-4-20246810xyLine 1: y = 2x + 1Line 2: y = -x + 4y = 2x + 1y = -x + 4Line 1 and Line 2 meet at (1, 3)(1, 3)Line 1 x-intercept (-0.5, 0)Line 1 y-intercept (0, 1)Line 2 x-intercept (4, 0)Line 2 y-intercept (0, 4)

Window: x -6 to 8, y -6 to 10.

Graph data as a table
Lines on the graph
LineEquationSlopey-interceptx-intercept
Line 1y = 2x + 121-0.5
Line 2y = -x + 4-144

How to Graph a Linear Equation

  1. Enter the line. Type the slope m and the y-intercept b of y = mx + b, or switch to Ax + By = C or x = c. Fractions such as 2/3 work in every box.
  2. Add more lines. Plot up to four, each with its own color, dash pattern and label, or start from a preset: an intersecting pair, parallel lines, perpendicular lines or two equations of the same line.
  3. Read the results. Intercepts are marked on the axes and every pair of lines gets its exact intersection point, or the reason it has none.
  4. Export. Download a sharp PNG for homework or slides, an SVG for print, or an Excel workbook with each line's slope, intercept and a table of points.

Slope-Intercept, Point-Slope and Standard Form

A straight line can be written three common ways. Slope-intercept form, y = mx + b, gives the slope m and the y-intercept b directly. Point-slope form, y - y1 = m(x - x1), is the quickest to write from one known point and the slope. Standard form, Ax + By = C, uses whole numbers with A positive and is the only one of the three that can describe a vertical line (B = 0). Two points mode gives all three for the line it finds.

Finding Where Two Lines Intersect

Two lines y = m1x + b1 and y = m2x + b2 meet where m1x + b1 = m2x + b2, so x = (b2 - b1) / (m1 - m2), and y follows from either equation. When m1 = m2 there is no single answer: the lines are parallel (different b) or the same line (same b). Perpendicular lines have slopes whose product is -1, such as 2 and -1/2; tick Equal scale to see the right angle drawn square.

Line of Best Fit and R²

In Data & regression, paste two columns or upload a CSV or Excel file. The tool fits the least squares line, the line that makes the sum of squared vertical distances (the residuals) as small as possible, and reports R², the share of the variation in Y the line explains. The residual lines on the graph show each of those distances. Use Predict y for x = to read a value off the line; the page warns when that x is outside your data, where the straight-line pattern may not hold. For a quick picture of the points without a fit, the scatter plot maker draws several series at once.

Doing the Same in Excel

For a line from data, put X in column A and Y in column B, then use =SLOPE(B2:B11,A2:A11) and =INTERCEPT(B2:B11,A2:A11); Excel takes the known y's first. =RSQ(B2:B11,A2:A11) gives R² and =STEYX(B2:B11,A2:A11) the standard error. To draw it, insert a scatter chart and add a linear trendline with "Display equation on chart". The Excel download from this page has all of this built in, with formulas that recalculate when you change a number. For percentage changes between two numbers, the percentage increase formula builder writes the formula for you.

Frequently Asked Questions

Related Tools