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
Where the lines meet
- Line 1 and Line 2:(1, 3)
Window: x -6 to 8, y -6 to 10.
Graph data as a table
| Line | Equation | Slope | y-intercept | x-intercept |
|---|---|---|---|---|
| Line 1 | y = 2x + 1 | 2 | 1 | -0.5 |
| Line 2 | y = -x + 4 | -1 | 4 | 4 |
How to Graph a Linear Equation
- 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.
- 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.
- 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.
- 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
Type the slope m and the intercept b for each line. The line crosses the y-axis at (0, b) and rises m units for every 1 unit to the right. The graph, the intercepts and any intersections update as you type.
Yes. Every box accepts decimals and fractions such as 3/4 or -1/2. Switch a line to Ax + By = C to enter standard form (the slope-intercept form is shown as you type), or to x = c for a vertical line.
Use Two points: enter (x1, y1) and (x2, y2). The slope is (y2 - y1) / (x2 - x1), and b = y1 - m × x1. The page shows the slope as a reduced fraction, the intercepts, slope-intercept, point-slope and integer standard form, and every step of the working.
Yes. Data & regression uses ordinary least squares from mean-centered sums, the same results as Excel's SLOPE, INTERCEPT, RSQ, CORREL and STEYX (known y's first, then known x's), and the Excel download contains those live formulas next to your data.
Lines with the same slope and different intercepts are parallel and never cross. Lines with the same slope and the same intercept are the same line and overlap everywhere. Any other pair meets at exactly one point, which is listed with a copy button even when it lies outside the graph window.
No. Equations, points and pasted or uploaded data are read, solved and drawn in your browser, and the PNG, SVG and Excel files are made there too.