Graph with Three Variables: How to Plot in 2D

Charts & pivot tables · Updated November 23, 2026

The direct answer: you can graph a function of three variables—typically written as z = f(x, y)—by using a 3D surface plot, a contour plot, or a heatmap, depending on what you want to emphasize. In Excel, the built-in 3D Surface and Contour chart types do this automatically; in Google Sheets, you use a heatmap with conditional formatting or a scatter plot with bubble size as the third variable.

What “Three Variables” Actually Means

In everyday math, a graph with three variables usually means one dependent variable (the output) and two independent variables (the inputs). For example, the cost of a product might depend on both the number of units produced and the cost of raw materials. The equation z = f(x, y) defines a surface in three-dimensional space, not a line or a curve.

This is different from a parametric curve in 3D, where three coordinates (x, y, z) are each functions of a single parameter t—like the path of a particle. When people ask “graph with three variables,” they almost always mean the surface case: two inputs, one output.

How to Create a 3D Surface Plot in Excel

Excel has a dedicated chart type for this. Here’s the shortest path in Microsoft 365 on Windows:

  1. Arrange your data in a grid: put the x-values in the first row, the y-values in the first column, and the z-values in the interior cells. For example, with x from 1 to 5 and y from 1 to 5, you’d have a 5×5 block of z values.
  2. Select the entire grid, including the row and column headers.
  3. Go to Insert > Charts > Insert Surface or Radar Chart.
  4. Choose 3-D Surface or Wireframe 3-D Surface.

On Mac, the path is the same: Insert > Chart > Surface. Excel for the web also supports surface charts, but the menu is under Insert > Chart > Surface.

Contour Plots: The 2D Alternative

If a 3D surface feels too flashy, a contour plot shows the same data as a topographical map. Each contour line connects points of equal z-value. Excel calls this a Contour chart, found in the same Surface menu. It’s often easier to read exact values from a contour plot than from a 3D surface, especially when you need to locate a maximum or minimum.

Contour plots are the standard in fields like meteorology (pressure maps) and geography (elevation maps). In Excel, the color bands between contour lines represent ranges of z-values, and the lines themselves show where the value is constant.

Using a Heatmap When You Only Have Two Variables

Sometimes people say “three variables” but actually have two categorical variables and one numeric value—for example, sales by product and by region. That’s a matrix, and the best visual is a heatmap. In Excel, you can use Conditional Formatting > Color Scales on the grid of numbers. In Google Sheets, the same feature exists under Format > Conditional formatting > Color scale.

A heatmap is not a true 3D graph, but it encodes the third variable as color intensity. It’s often more practical than a surface plot when the data is categorical rather than continuous.

Common Problems and How to Fix Them

The most frequent issue when graphing three variables in Excel is the data layout. Excel’s surface chart expects a rectangular grid, not a list of x, y, z triples. If your data is in three columns (x in A, y in B, z in C), you must first pivot it into a grid. Use a pivot table or the UNIQUE and TRANSPOSE functions to reshape it.

Another common problem: the axes appear reversed. Excel plots the first row as the x-axis and the first column as the y-axis. If your surface looks mirrored, swap the row and column headers.

If your surface looks jagged, it’s because the data points are sparse. Interpolate more points by computing z for a finer grid of x and y values, or use a smoother chart type like a filled contour.

Alternatives: Bubble Charts and Scatter Plots

When you have three numeric variables but no clear dependent variable, a bubble chart is a good alternative. In a bubble chart, x and y are plotted normally, and the size of each bubble represents the third variable. For example, plotting GDP per capita (x) against life expectancy (y) with bubble size equal to population.

In Excel, select your three columns (x, y, and bubble size), then go to Insert > Scatter > Bubble. In Google Sheets, the same chart type is under Insert > Chart > Chart type > Bubble chart.

Bubble charts are easier to read than 3D surfaces when you have discrete data points rather than a continuous function.

How to Choose the Right Chart

Ask yourself what you want the reader to see:

  • Shape of a continuous function → 3D Surface or Wireframe
  • Exact values and local maxima/minima → Contour plot
  • Patterns in a categorical matrix → Heatmap with conditional formatting
  • Relationship with a third numeric variable → Bubble chart

For a formal report, contour plots often look more professional than 3D surfaces because they don’t hide data behind perspective. For a quick exploratory look, a 3D surface is intuitive.

Frequently Asked Questions

Can I graph three variables in Google Sheets?

Yes, but Google Sheets lacks a native 3D surface chart. The best workaround is a bubble chart (Insert > Chart > Bubble chart) or a heatmap using conditional formatting. For a true surface plot, you’d need to export the data to Excel or use a third-party add-on.

What is the difference between a surface plot and a contour plot?

A surface plot shows a 3D shape with height representing the z-value. A contour plot flattens that shape into a 2D map where lines or color bands connect points of equal z-value. Contour plots are easier to read exact values from, while surface plots better convey the overall shape.

How do I add a third variable to a scatter plot?

You can encode the third variable as bubble size, color, or even marker shape. In Excel, a bubble chart uses the third column for size. For color, you’d need to manually format each point or use a scatter plot with series based on categories.

Why does my Excel surface chart look wrong?

Most likely the data isn’t in the required grid format. Surface charts in Excel need the z-values in a rectangular block with x and y labels on the edges. If your data is in three columns, pivot it first. Also check that the first row and first column are numeric, not text.

Can I graph a function like z = x² + y² in Excel?

Yes. Create a grid of x and y values (say from -5 to 5 in steps of 1), then type a formula in the top-left cell of the z-block, like =A2^2+B1^2 (adjusting for your cell references). Fill the formula across and down. Then insert a surface chart.

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.