Contour plot: read a response surface from above

Updated

A contour plot shows how a response changes over two variables, like a topographic map. The two variables form the horizontal and vertical axes, and lines (contours) join the points where the response has the same value, often with colored bands between them. Hills, valleys, ridges and saddles in the response become rings, nested ovals and crossing patterns you can read off directly, with exact coordinates. It is the standard way to look at a fitted model from a response surface design.

When to use it

  • You have a model, usually from a designed experiment, that predicts a response from two factors, and you want to find the best settings.
  • You need an operating window: the region of settings where the response stays above (or below) a target.
  • You want to see interactions: when the effect of one factor depends on the level of the other, contours tilt.
  • You have measurements on a regular grid, such as thickness across a plate, and want a map of them.

How it works

  1. Define a grid over the two variables, for example 50 × 50 points across the experimental region.
  2. Compute the response at each grid point, from the fitted equation or by interpolating measured values.
  3. Choose contour levels, such as every 1% of yield.
  4. Trace the line where the response crosses each level, interpolating between grid points.
  5. Optionally fill the bands between levels with a color scale, and label the lines with their values.

If the model has more than two factors, the plot holds the others at fixed values, which should be stated on the plot. Changing them changes the picture.

For a quadratic model, the shape of the contours follows from the signs of the curvature: closed ovals around a maximum or minimum when both curvatures have the same sign, a saddle (crossing hyperbolas) when they differ, and long parallel bands when one curvature is near zero (a ridge).

Example

A chemical plant studied batch yield against reactor temperature (150 to 190 °C) and reaction time (20 to 60 minutes) with a central composite design. In coded units, x₁ = (temperature − 170) / 10 and x₂ = (time − 40) / 10, the fitted model is:

Yield = 82 + 2.1x₁ + 1.4x₂ − 1.8x₁² − 1.2x₂² − 0.9x₁x₂

Evaluating it on a coarse grid gives the values a contour plot is built from (yield in %):

Time \ Temperature150 °C160 °C170 °C180 °C190 °C
60 min72.277.980.078.573.4
50 min72.679.282.281.677.4
40 min70.678.182.082.379.0
30 min66.274.679.480.678.2
20 min59.468.774.476.575.0

Drawn with contours every 2% (on a fine grid), the plot shows nested ovals around a peak:

  • The optimum. Setting the slopes of the model to zero gives the stationary point at x₁ = 0.48, x₂ = 0.40, that is 174.8 °C and 44.0 minutes, with a predicted yield of 82.8%. Both curvatures are negative, so it is a maximum.
  • The operating window. The 82% contour encloses roughly 168 to 182 °C and 36 to 53 minutes. Anywhere inside, the predicted yield is within 0.8 points of the peak. The 80% contour is much wider, from about 162 to 188 °C, and runs off the top edge of the region at 60 minutes.
  • The tilt. The ovals are stretched from upper left to lower right because of the negative interaction term (−0.9x₁x₂). A hotter reactor needs a shorter batch: 165 °C for 50 minutes gives 81.2%, and 180 °C for 35 minutes gives 81.8%. Along that direction the yield falls off about half as fast as across it.

That tilt is useful to the plant. If cycle time matters more than energy, it can run hotter and shorter and lose little yield. A one-factor-at-a-time study, which changes temperature at a fixed time and then time at a fixed temperature, could easily miss it.

How to read the results

  • Closed rings mark a peak or a pit; the value labels tell you which.
  • Spacing shows steepness: lines close together mean the response changes fast; far apart, it is flat and forgiving.
  • Tilted ovals or bands mean the factors interact.
  • Contours that run off the edge mean the best region may lie outside the tested range. Do not extrapolate; run more experiments in that direction.
  • Distance from the data. A model is only trustworthy inside the region the design covered.

Common mistakes

  • Ignoring the other factors. With three or more factors, a contour plot is one slice. Check slices at other settings, or use a response optimizer.
  • Trusting a poor model. Contours from a model with a low R² or significant lack of fit draw a confident map of noise.
  • Reading values between widely spaced contours too precisely. Add more levels or evaluate the model at the point.
  • Choosing a color scale that hides the order. Use a scale that runs from light to dark, not a rainbow, so readers can tell high from low.

Frequently asked questions

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

They show the same function. A 3D surface plot draws it as a landscape seen in perspective, which is good for a first impression. A contour plot views it from directly above, which makes it easier to read exact settings and values.

Why are my contours ovals tilted at an angle?

Because the two factors interact: the best level of one depends on the level of the other. Ovals aligned with the axes mean no interaction.

What does a saddle shape mean?

The response rises in one direction and falls in another from the stationary point, so that point is neither a maximum nor a minimum. The best settings lie at the edge of the region, and a response optimizer can find them.

Can I make a contour plot from raw data?

Yes, if the data cover a grid or can be interpolated onto one. With scattered points, interpolation can invent features between them, so keep the original points visible.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab