Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Plot a Graph in Excel with Two Variables

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Plotting a graph with two variables in Excel creates a scatter plot or line chart that shows the relationship between them—ideal for identifying trends, correlations, or patterns in numerical data. You need a dataset with two columns: one for the horizontal (x-axis) variable and one for the vertical (y-axis) variable.

What You'll Need

  • Microsoft Excel installed (Excel for Microsoft 365, Excel 2021, Excel 2019, or later; steps apply to Windows and macOS versions)
  • A worksheet with at least two columns of numerical data, where each row represents a paired observation (e.g., height and weight, time and temperature)
  • No add-ins or special permissions required

Step-by-Step

  1. Open your Excel workbook and ensure your data is arranged in two adjacent columns, with column headers clearly labeled (e.g., "X-Value" in A1 and "Y-Value" in B1). Place your cursor anywhere inside the data range—you don’t need to select the entire range yet.
  2. Go to the Insert tab on the Excel ribbon (top of the window).
  3. In the Charts group, locate the Scatter (X, Y) chart icon (it looks like a cluster of dots). Click the small downward arrow next to it to reveal sub-options.
  4. Choose Scatter with Only Markers (the top-left icon) for a basic two-variable scatter plot. If your x-values are sequential (e.g., 1, 2, 3...) and you want to emphasize change over time or order, you may instead select Line under the Line chart icon—but for true two-variable relationships, Scatter is preferred.
  5. Excel will insert the chart on the same sheet. Now, verify that Excel correctly assigned the columns: hover over the chart to see the chart elements. Click the chart to activate Chart Tools, then go to the Chart Design tab. Click Select Data in the Data group.
  6. In the Select Data Source dialog box, confirm the Legend Entries (Series) section shows your data series. Under Series name, check that it references your y-axis column header (e.g., =Sheet1!$B$1). Under Series X values, ensure it points to your x-axis data range (e.g., =Sheet1!$A$2:$A$11), and Series Y values points to the y-axis data (e.g., =Sheet1!$B$2:$B$11). If not, click Edit and manually reselect the correct ranges. Click OK to apply.
  7. Customize your chart: click the chart to reveal the Chart Elements button (the plus sign +). Check Axis Titles and Chart Title. Click each to edit: rename the chart (e.g., "Sales vs. Advertising Spend"), then click the horizontal axis title and type your x-variable name, and do the same for the vertical axis.
  8. For better clarity, right-click any data point on the chart and choose Add Trendline. In the sidebar that appears, select Linear under Trendline Options to visualize the overall relationship. Check Display Equation on chart and Display R-squared value on chart if you want to see the correlation strength and mathematical model.

Common Mistakes

  • Swapping X and Y axes: Excel assumes the first selected column is the x-axis. If your chart shows unexpected patterns, check the Select Data dialog to confirm which column maps to which axis.
  • Including non-numeric data: Text, blanks, or error values (like #N/A) in your data range can cause gaps or incomplete plots. Clean your dataset first—use Filter to find and fix inconsistencies.
  • Using Line instead of Scatter for non-sequential x-values: Line charts connect points in order of appearance and may misrepresent relationships if x-values are not evenly spaced (e.g., dates or categories). Scatter plots use actual x-values for spacing, giving accurate representation.
  • Forgetting to label axes: Unlabeled axes make the chart meaningless to others. Always add axis titles describing the variable and units (e.g., "Time (hours)", "Temperature (°C)").
  • Accidental data selection outside the intended range: If your chart includes extra rows or columns, reselect only the two relevant columns before inserting the chart. Use Ctrl+Shift+End (Windows) or Cmd+Shift+End (macOS) to verify your range.

Tips

  • Use consistent scales: Right-click an axis > Format Axis > adjust Minimum and Maximum bounds to avoid distorted visuals (e.g., don’t start the y-axis at 100 when your data ranges from 95–105).
  • Color-code for groups: If comparing multiple series (e.g., two products over time), add a third column for category and create separate series for each group via Select Data.
  • Export for reports: Right-click the chart > Save as Picture to export as PNG or EMF for use in Word, PowerPoint, or email—high resolution is preserved.
  • Update automatically: Your chart updates instantly when source data changes. If it doesn’t, check if Calculate is set to Automatic under Formulas > Calculation Options.
  • Use keyboard shortcuts: Press Alt+N+V+S (Windows) or Cmd+Shift+F1 (macOS) to quickly insert a scatter plot after selecting your data.

Troubleshooting

If your graph looks wrong or won’t generate, try these fixes in order:

  • No chart appears: Ensure you selected two columns of data before clicking Insert > Scatter. If you selected only one column, Excel defaults to a line chart using row numbers as x-values—reselect the correct range.
  • Points are missing or misaligned: Look for hidden blanks or text entries. Press Ctrl+G > Special > Blanks to find empty cells, or use Filter to spot non-numeric entries. Replace blanks with zeros if appropriate, or delete rows with invalid data.
  • Axis labels show numbers instead of text: You likely selected the wrong range in Select Data Source. Reopen that dialog, select your series, and reassign the Series name to the header cell (e.g., =Sheet1!$B$1—not the data range).
  • Chart distorts when resized: Right-click the chart area > Format Chart Area > under Size & Properties, uncheck Lock aspect ratio if you’re forcing nonstandard dimensions. Better yet, drag the chart border to resize proportionally.
  • Excel crashes or hangs during chart creation: Try inserting the chart into a new blank worksheet. If the issue persists, repair Excel: File > Options > Advanced > scroll to Display and uncheck Show chart tools in the ribbon (temporarily), then restart Excel. As a last resort, save your file as .xlsx (not .xls) and reopen.

Frequently Asked Questions

Can I plot two variables with different units on the same chart?

Yes. After creating the scatter plot, right-click a data series > Format Data Series > check Secondary Axis. This adds a second vertical axis on the right, scaled independently for the second variable’s units.

Why does Excel connect my points with lines even though I chose Scatter?

It shouldn’t—the Scatter with Only Markers option avoids lines. If you see lines, you may have accidentally selected a Line chart. Delete the chart, reselect your data, and choose Scatter again. Also, verify no trendline was auto-added; right-click the chart line > Clear to remove it.

How do I add a third variable (like size or color to represent magnitude)?

For color: Create separate series for each category (e.g., Region A, Region B) and assign distinct colors via Select Data > Edit > Fill. For size: Use a Bubble chart instead (Insert > Bubble)—add a third column with size values and select all three columns before inserting.

Can I plot non-adjacent columns (e.g., A and C instead of A and B)?

Yes. Hold Ctrl (Windows) or Command (macOS) while selecting the first column, then the second column. Then go to Insert > Scatter. Excel will still create a valid two-variable plot, though adjacent columns are easier to manage.

My chart shows #VALUE! or #NAME? errors—how do I fix it?

These errors come from invalid data in the source cells. Use Excel’s Error Checking (Formulas > Error Checking) or filter for errors (Filter > Filter by Color > Error Cells). Replace erroneous values with numbers or remove the row. If your formula includes text (e.g., "N/A"), convert it to a blank or numeric placeholder.

How do I change the chart type after creating it?

Select the chart > Chart Design tab > Change Chart Type. Choose Scatter or Line from the list. You can also right-click the chart > Change Chart Type for the same menu. All data series will retain their mapping unless the new chart type is incompatible (e.g., converting to Pie will fail).