The idea: multiply x by sx and y by sy

A scaling matrix stretches or compresses the plane along the two axes. It has the two scale factors on its diagonal and zeros everywhere else:

S=[sx00sy],S[xy]=[sxxsyy]

Each new coordinate depends on one old coordinate only: the zeros say that x never leaks into y. The columns are where the basis vectors land: î = (1, 0) goes to (sx, 0) and ĵ = (0, 1) goes to (0, sy). Grid lines stay parallel to the axes; only the spacing changes.

Left: the square grid with the unit square shaded, the unit circle in purple and the letter F in orange. Right: after S = [2 0; 0 1.5] the grid cells are 2 wide and 1.5 tall, the unit square is a 2 by 1.5 rectangle of area 3, the circle is an ellipse with semi-axes 2 and 1.5, and the F is wider and taller
S = [2 0; 0 1.5] makes everything 2 times wider and 1.5 times taller: the unit square becomes a 2 × 1.5 rectangle of area 3.

On the canvas the grey grid stays put and is the ruler. The blue grid, the red î, the green ĵ, the shaded unit square, the purple unit circle and the orange F all move with S. Pick sx or sy and the plane morphs; a grey copy keeps the picture from before. The matrix panel shows S as a formula and as numbers, with column 1 in red and column 2 in green.

A point, row times column

For v = (2, 1) and S = [2 0; 0 1.5], row 1 gives 2·2 + 0·1 = 4 and row 2 gives 0·2 + 1.5·1 = 1.5, so S·v = (4, 1.5). Every row has one zero, so each new coordinate is just the old one times its factor. Pick v in the control bar to see the two products fly into the point panel.

Uniform and non-uniform scaling

When sx = sy = k the scaling is uniform: S = k·I. Every length is multiplied by |k|, and shapes and angles are kept: a circle stays a circle, a square stays a square. Only the size changes (Demo: Uniform: double everything (area ×4)).

When sx ≠ sy the scaling is non-uniform. The plane is pulled harder along one axis than the other, so the unit circle x² + y² = 1 becomes the ellipse (x/sx)² + (y/sy)² = 1 with semi-axes |sx| and |sy|, and angles change (Demo: Stretch x only: circle → ellipse).

Left: uniform scaling by 2 turns the unit circle into a circle of radius 2 and keeps the right angle between the arrows (1, 1) and (−1, 1). Right: stretching x by 2 turns the circle into an ellipse with semi-axes 2 and 1, and the same two arrows become (2, 1) and (−2, 1), which meet at about 127 degrees instead of 90
Uniform ×2 keeps the circle round and the right angle a right angle; stretching x only makes an ellipse and the right angle opens to about 127°.

The determinant sx·sy is the area factor

The unit square goes to an |sx| × |sy| rectangle, so every area is multiplied by |sx·sy|. That product is the determinant: det S = sx·sy − 0·0 = sx·sy (Demo: Area = sx·sy).

Sdetunit square becomeswhat happens
[2 0; 0 2]42 × 2 squareuniform, area ×4
[3 0; 0 1]33 × 1 rectanglestretch x, circle → ellipse
[2 0; 0 ½]12 × ½ rectanglearea kept, shape changed
[−1 0; 0 1]−11 × 1 square, mirroreda flip across the y-axis
[2 0; 0 0]0a segmentcollapse onto the x-axis

[2 0; 0 ½] is worth a second look: det = 1, so no area is gained or lost, yet the circle is an ellipse. Keeping area is not the same as keeping shape.

Negative factors flip

A negative factor scales and mirrors. sx = −1 swaps left and right: the F faces the other way and det = −1 < 0 says the orientation flipped (the turn from î to ĵ is now clockwise). Make sy = −1 as well and the two mirrors cancel: [−1 0; 0 −1] = −I has det = +1 and is a 180° turn, the same as the rotation matrix for 180° (Demo: Negative factor: a flip). A single −1 factor is a reflection across an axis.

Three panels with the letter F. Left: the identity, det 1. Middle: S = [−1 0; 0 1], the F is mirrored left to right, det −1. Right: S = [−1 0; 0 −1], the F is upside down and turned, not mirrored, det 1
One negative factor mirrors the F (det < 0); two negative factors are a half turn (det > 0).

The axes are the eigenvectors

A vector on the x-axis, (x, 0), goes to (sx·x, 0) = sx·(x, 0): it stays on its line and only gets longer or shorter. So the x-axis is an eigenvector direction with eigenvalue λ = sx, and the y-axis one with λ = sy. Any other vector has both coordinates non-zero, they are multiplied by different numbers, and the vector turns toward the axis with the bigger stretch. With S = [2 0; 0 ½], (1, 1) goes to (2, ½), off the line through (1, 1) (Demo: Eigenvectors: the axes only stretch). When sx = sy every vector is an eigenvector.

Diagonal matrices are the easiest ones there are, and that is the point of diagonalisation: in a basis of eigenvectors, many matrices become a plain scaling.

A zero factor collapses; the inverse divides

With sy = 0 every point lands on the x-axis: the plane is squashed to a line, det = 0, and every point of a vertical line lands on the same spot. Nothing can send them back, so there is no inverse (Demo: Zero: collapse onto a line (no inverse)). When neither factor is 0, undo each axis on its own:

S−1=[1/sx001/sy],detS−1=1sxsy

For S = [2 0; 0 1.5] that is [½ 0; 0 ⅔]. Press Inverse to watch it shrink the picture back to the start. Two scalings in a row multiply their factors: [a 0; 0 b]·[c 0; 0 d] = [ac 0; 0 bd], so scalings commute (see Matrix Multiplication).

Stretching along another direction

To stretch along a tilted line, turn that line onto the x-axis, scale, and turn back: R·S·R⁻¹. The result is a symmetric matrix that is no longer diagonal, with the tilted line and its perpendicular as eigenvectors. Every matrix is a rotation, a scaling and another rotation (the SVD, see SVD and PCA).

See also the overview Linear Transformations and the other basic transforms: Rotation Matrix, Reflection Matrix, Shear Matrix and Projection Matrix. Scaling of a picture in graphics is shown in Rotation and Scaling in 2D.

What the page leaves out

Scaling about a point other than the origin (it needs a translation, so 3×3 homogeneous matrices in graphics), stretches along tilted directions drawn on the canvas, 3D scaling diag(sx, sy, sz), factors outside −2 … 3, and how scaling is used for image resizing (resampling and filtering).