Contour plotHeight lines for crowded dots.
Rings like the height lines on a hiking map. Tight rings are steep, the inner ring is the peak, and two sets of rings are two groups.
- Answers Do two things move together?
- Your data two numbers per item
- Items about 200 or more
- Lines about 3 to 8 levels
- Excel and Power BI not built in
What is a contour plot?
A contour plot (here a 2D density plot) draws rings around where the dots of a scatter plot crowd, like the height lines on a hiking map. Each ring joins places of equal density: the inner rings are the peaks where most points sit, and two separate sets of rings mean two groups.
A park ranger times 270 eruptions of a geyser: how long each one lasts and how long visitors waited for it. The rings show two peaks: short eruptions after a short wait, and long eruptions after a long one.
Why use a contour plot?
Because it shows the shape of a crowd without drawing every dot.
- Peaks and groups. Two sets of rings are two groups.
- Smooth. No blocky cells, no bin size to pick.
- Calm with big data. Thousands of points become a few lines.
- Familiar. Anyone who has read a hiking map reads rings.
How does a contour plot work?
Four steps turn dots into height lines.
- Step 1 of 4The dots270 eruptions, one dot each.
- Step 2 of 4A smooth hillCount where the dots crowd; smoothing turns the counts into a hill.
- Step 3 of 4Cut the hillLines at four heights, like height lines on a map.
- Step 4 of 4Dots under the ringsThe faint dots stay, so the reader sees the real data.
What are the parts of a contour plot?
Four parts, and each one has a job.
- Peakwhere the dots crowd most
- Outer ringthe edge of where most dots are
- X axisthe first number
- Y axisthe second number
How do you read a contour plot?
Three looks, in this order.
- Count the peaksTwo sets of rings: two kinds of eruption.
- Read where they sitShort eruptions follow waits of about 55 minutes, long ones about 80.
- Compare their sizeThe long-eruption peak has more rings inside: it is the more common kind.
What kinds of contour plot are there?
The same eruptions, three ways.
- Kind 1Rings over dotsLines with the faint dots underneath.
- Kind 2Rings onlyThe lines alone: the cleanest look.
- Kind 3HexagonsCounted cells instead of smooth rings.
Contour plots are also used for any number that depends on two others, like height on a map or temperature over a field; there the rings join equal values, not equal density.
When should you use a contour plot?
When many points form crowds and you want their shape.
- there are about 200 points or more
- there may be several groups
- the shape of the crowd matters
- readers know height lines
- there are few points (a scatter plot)
- exact counts matter (a hexbin plot)
- single items matter (a scatter with names)
Contour plot or hexbin plot?
Rings for the smooth shape, hexagons for the counts.
The hexbin plot counts real points per cell, so it is exact but blocky. The contour plot smooths the counts into rings, which shows the two peaks more calmly but depends on how much smoothing is used.
How do you make a contour plot?
Not built into Excel or Power BI; one line in Python or R.
In Python, seaborn's kdeplot with an x and a y column draws density rings, and fill=True shades between them. In R, geom_density_2d in ggplot2 does the same. In Power BI, run that code in a Python or R visual (Python and R visuals in Power BI).
What goes wrong with contour plots?
The most common mistake, and its fix: rings over too few points.
- about 200 points or more
- the faint dots underneath
- or a plain scatter for small data
| Mistake | Why it hurts | Fix |
|---|---|---|
| Too few points | The rings are invented | About 200 or more, dots underneath |
| Too much smoothing | Two peaks melt into one | Check against a hexbin plot |
| Too many levels | A tangle of lines | About 3 to 8 levels |
| No dots at all | Readers forget it is data | Faint dots under the rings |
| Unlabelled axes | The peaks mean nothing | Name both axes with units |
Every chart for “Do two things move together?”
- Two numbersScatter plotOne dot per item, two numbers as its position.
- Two numbersTrend lineThe straight line that best fits a scatter of dots.
- Two numbersHexbin plotA scatter with too many dots, counted in hexagons.
- Three numbersBubble chartA scatter plot whose dot size is a third number.
- Many numbersScatterplot matrixA scatter plot for every pair of numbers, in a grid.
- Many numbersCorrelation matrixA grid of how strongly each pair of numbers moves together.
- Two categoriesHeat mapA grid where colour shows the value, so patterns jump out.
- Two categoriesQuadrant chartA scatter split into four boxes, for sorting items into groups.
Read on, step by step.
Does it fit your data? Try it.
Paste your table into Chart Compass, say what the chart should show, and see the charts that fit, drawn with your own numbers. It runs in your browser, so the data stays with you.