X and Y Line Graph in Excel: Create and Format It

Charts & pivot tables · Updated November 22, 2026

In Excel, use an XY scatter chart with straight lines when your X values are numbers that must determine each point’s horizontal position; choose a line chart when the X values are categories such as months or names. To make an XY graph in Microsoft 365 for Windows, arrange X values in one column and Y values in the next, select both columns, then choose Insert > Insert Scatter (X, Y) or Bubble Chart > Scatter with Straight Lines and Markers.

What an X and Y line graph shows

An X-Y graph plots paired values: each observation has an X coordinate and a corresponding Y coordinate. The horizontal axis is the X-axis, and the vertical axis is the Y-axis. A point at (3, 12), for example, represents an observation whose X value is 3 and Y value is 12. Connecting the points with lines makes changes across the observations easier to follow.

People often call this an X and Y line graph, but in Excel the chart type that handles two numeric axes is an XY scatter chart. It can display markers alone, connect the markers with straight lines, or connect them with smoothed lines. The choice matters: in a scatter chart, the numeric distance between X values affects the horizontal spacing. A point at X = 10 is twice as far from X = 0 as a point at X = 5.

A conventional line chart looks similar, but generally uses the horizontal axis for categories. It spaces categories evenly, even when the labels look like numbers. That is useful for a sequence of equally spaced periods, but it can misrepresent data when numeric X intervals are unequal.

Prepare the data in two columns

Put each X value on the same row as the Y value it belongs with. Add clear headers in the first row, such as Distance and Temperature, and keep the data in a simple rectangular range. For example, if time is the independent variable and a sensor reading is the dependent variable, each row should hold one time-reading pair.

  • Column A: X values, such as elapsed seconds: 0, 2, 5, and 9.
  • Column B: corresponding Y values, such as measured readings: 4, 7, 11, and 13.
  • Each row must represent one paired observation; do not sort one column independently from the other.

For an XY scatter chart, X values should be numeric or dates that Excel recognizes as dates. If values that should be numbers are stored as text, Excel may not plot them as intended. Check for leading apostrophes, inconsistent decimal separators, or imported text values. A blank row can also make a chart appear discontinuous or incomplete, depending on the chart settings and data layout.

Create the XY chart in Excel

  1. Select the X and Y columns, including their headers. If the columns are side by side, drag across the entire range. If they are separate, select the first range and hold Ctrl while selecting the second range on Windows.
  2. Open the Insert tab, choose Insert Scatter (X, Y) or Bubble Chart, and select Scatter with Straight Lines and Markers. Excel creates a chart with markers joined in the order of the source rows.
  3. Click the chart title and type a descriptive title. A useful title says what is being measured, rather than merely calling it Graph.
  4. Add axis titles from Chart Design > Add Chart Element > Axis Titles, then choose Primary Horizontal and Primary Vertical. Click each title placeholder and enter the variable name and, where useful, its unit.

If the chart has the wrong values or axes, right-click the chart and choose Select Data, or use Chart Design > Select Data. Select the series and choose Edit to check the Series X values and Series Y values ranges. For example, the X range should point to the numeric data in the first column and the Y range to its paired readings in the second column. Exclude the header cells from these value ranges if Excel has included them incorrectly.

On Excel for Mac, the chart types and series-editing options are similar, though their placement or wording can vary slightly with the ribbon layout. Use the Insert tab to add a scatter chart and the chart design controls to edit its data and elements. For multiselecting nonadjacent ranges, use Command rather than Ctrl.

Choose between a scatter chart and a line chart

Choose based on what the horizontal values mean, not just on the fact that you want points joined by a line. A scatter chart is usually the right option when X is a measured quantity, such as speed, age, distance, or elapsed time, and gaps between X values have meaning. It also suits comparing two measurements, such as advertising spend and sales, when neither variable is simply a category label.

A line chart is often better for observations recorded at regular intervals, such as monthly totals or daily readings, when the goal is to compare a sequence of categories. It gives each category an even slot. If your month labels are January, February, and March, that is usually appropriate. But if numeric X values are 1, 2, and 100, a line chart may display those three categories at equal intervals, while a scatter chart preserves the large gap from 2 to 100.

There is a related nuance with dates. A line chart can use dates on its horizontal axis and may display them as a date axis, giving time intervals a more calendar-aware treatment. Still, when precise numeric X spacing is central to the question, an XY scatter chart is the more direct choice. Verify the axis behavior rather than assuming that every chart labeled Line treats the horizontal values as measured coordinates.

Format the axes and data markers

Formatting should make the chart easier to read without changing what the data say. Add axis titles that identify both the quantity and its unit, such as Time (seconds) and Distance (meters). If values have many decimal places, format the axis labels to show a sensible level of precision. Select an axis, open Format Axis, and adjust its bounds, units, number format, or label options as needed.

Automatic axis limits are suitable for many charts, but they can hide useful detail or make variation look larger or smaller than expected. Setting a minimum or maximum can focus attention on a relevant range; however, a vertical axis that starts above zero can visually exaggerate changes. State the scale clearly and choose bounds that match the purpose of the chart. Avoid changing the scale simply to make a trend look more dramatic.

Markers help readers locate individual observations, particularly when there are only a few points. With dense data, large markers can overlap and obscure the line, so smaller markers or a line without markers may be clearer. To adjust appearance, select a series and use the formatting controls for its line and marker. Keep colors and line styles distinct if the chart contains multiple series, and do not rely on color alone when the graph may be printed in grayscale.

Plot more than one data series

An XY scatter chart can compare multiple Y series against the same X values. A common layout has X values in column A and separate Y series in columns B and C, with a header above each series. Select the complete range and insert the scatter chart; Excel will often interpret the columns as separate series. Check the result, especially if the chart has assigned a column of labels or values to the wrong axis.

To correct it, open Select Data and edit each series. Give it a meaningful series name, point its X values to the shared X range, and point its Y values to the appropriate column. All X and Y ranges for a series must contain the same number of data points. A legend is useful when there are several series, but rename vague entries such as Series 1 using clear column headers or the series-name setting.

Use a second vertical axis only when the series have substantially different units or scales and a single scale would make one series unreadable. A secondary axis can make comparisons misleading because the two scales are independent. Label both axes conspicuously and explain the units; if the goal is to compare patterns rather than raw magnitudes, separate charts may be easier to interpret.

Common problems and how to fix them

  • The X-axis shows 1, 2, 3 instead of the intended values: Excel may have created a line chart or may not have assigned the X range. Change the chart type to XY scatter, then inspect the series X values in Select Data.
  • The points appear in an unexpected order: Excel connects points in source-row order; it does not automatically sort them by X. Sort the complete table by the X column, keeping each row together, if the intended line should progress from the smallest X value to the largest.
  • The chart has only one series or odd labels: Check the selected range and headers. Use Select Data to remove an unintended series or edit its X and Y ranges.
  • Some points are missing: Look for blank cells, text in numeric columns, filtered or hidden data, and values outside the displayed axis bounds. Confirm the chart’s treatment of empty cells if gaps are involved.
  • The line looks jagged or overlaps itself: This may reflect real variation, unsorted X values, duplicate X values, or a crowded chart. Check row order and the underlying measurements before changing the visual style.

What connecting the points does—and does not—mean

A line between observed points helps show direction and sequence, but it does not prove that values between the observations were measured. A straight segment visually suggests a simple connection between endpoints; the real relationship may curve or change sharply between them. Be especially cautious when measurements are sparse, when X values are irregularly spaced, or when the data come from separate groups.

A scatter chart with markers and no connecting line is often better for investigating whether two variables are associated, because it avoids implying a continuous path through the observations. A connected scatter plot is more appropriate when the order matters, such as a measurement changing over time. A trendline is another option for summarizing a pattern, but it is a fitted model rather than a line that simply joins each pair of adjacent observations. Use it only when the model form is suitable for the data and label it clearly.

Frequently Asked Questions

How do I make an X and Y graph in Excel?
Place X values in one column and paired Y values in another, select both columns, and choose Insert > Insert Scatter (X, Y) or Bubble Chart > Scatter with Straight Lines and Markers. Add axis titles so readers can identify each variable.

Is an XY graph the same as a line graph?
Not exactly. An XY scatter chart positions points using numeric values on both axes. A standard line chart generally treats horizontal values as categories and spaces them evenly. Both can show connected points, but they represent the X-axis differently.

How do I change which column is the X-axis in Excel?
Open the chart’s Select Data controls, select the series, choose Edit, and set the Series X values to the intended X range. Set Series Y values to the matching Y range and make sure both ranges contain the same number of data points.

Should I sort the X values before making the graph?
Sort by X if you want the line to run from lower to higher X values. Sort entire rows, not just the X column, so each X value stays paired with its original Y value. Do not sort if the row order represents a meaningful sequence that should remain intact.

Can I make an X and Y graph with multiple lines?
Yes. Add each Y series as a separate series and assign the appropriate X range to it. Use clear series names and check the ranges in Select Data; every series needs matching X and Y point counts.

Related

Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.

More in Charts & pivot tables

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.