Scatter plot clustering in 3D

A 3D scatter plot on axes, with blue, green and purple spheres grouped into three distinct clusters.Drag to turn

A scatter plot draws each observation as a point using two numeric variables. Clustering is a method that groups observations so that points in the same group are more similar to each other than to points in other groups.

What a scatter plot shows

A scatter plot places one variable on the horizontal axis and another on the vertical axis. Each row of data becomes one point. The pattern of points shows the direction, strength and shape of a relationship. It also exposes outliers, which are points far from the rest.

A cluster appears as a dense group of points separated from other groups by emptier space. Clusters often hint that the data mixes several subgroups.

How clustering algorithms find groups

Clustering is a form of unsupervised learning, meaning no labels are supplied. The algorithm judges similarity with a distance measure, usually Euclidean distance.

K-means is the standard example. The analyst picks k, the number of clusters. The algorithm places k centroids, assigns each point to the nearest one, moves each centroid to the mean of its points, and repeats until assignments stop changing.

A small k-means example with six points

Take six points: A(1,1), B(2,1), C(1,2), D(8,8), E(9,8) and F(8,9). Start with centroids at A(1,1) and E(9,8). Point D is at distance 1 from E, and at about 9.9 from A, because the square root of 49 plus 49 is about 9.9. So D joins E. F also joins E, while B and C join A.

The new centroid for A, B and C is ((1+2+1)/3, (1+1+2)/3) = (1.33, 1.33). For D, E and F it is ((8+9+8)/3, (8+8+9)/3) = (8.33, 8.33). Reassigning gives the same groups, so the algorithm stops.

Common misconceptions

Visible or computed clusters are not proof of real groups. K-means returns k clusters even when the data has no real structure, so the result needs checking against domain knowledge.

Scale matters. If one variable is in thousands and another in single digits, distance is dominated by the larger one, so variables are usually standardized first. K-means also suits roughly round clusters and handles curved shapes poorly. Density-based methods such as DBSCAN can suit those shapes better.

Where these tools are used

Retailers group customers by spending and visit frequency. Biologists group genes by expression pattern. Image tools group pixels by colour. Analysts often colour scatter points by cluster label to inspect the result by eye.

Key terms

Scatter plot
A chart that shows each observation as a point positioned by two numeric variables.
Cluster
A group of observations that are closer to each other than to the rest of the data.
Centroid
The mean position of the points in a cluster.
K-means
A clustering algorithm that repeatedly assigns points to the nearest centroid and recomputes the centroids.
Euclidean distance
The straight-line distance between two points.
Outlier
A point that lies far from most of the other points.
Unsupervised learning
Learning patterns from data that has no labels.

Common questions

How is the number of clusters k chosen?

Common approaches are the elbow method, which plots within-cluster squared distance against k and looks for a bend, and the silhouette score. Domain knowledge also matters.

How does clustering differ from classification?

Classification learns from labelled examples. Clustering has no labels and finds groups from the features alone.

Can a scatter plot handle more than two variables?

Each plot has two axes, though colour, point size or a grid of plots can add more. Methods such as principal component analysis can reduce many variables to two before plotting.

Learn this with a tutor

Sidechair's AI tutor will teach this topic in 3D. Join the waitlist for early access.

We'll only email you about Sidechair. Read our privacy policy.