Mosaic Plot

Visualises the joint distribution of two categorical variables — column widths show the marginal frequency, segment heights show the conditional shares.

Anatomy of a Mosaic Plot

The mosaic plot shows the joint distribution of two categorical variables. Unlike a stacked bar chart — where every column has the same width — the mosaic plot encodes the marginal distribution of both variables geometrically: column widths and segment heights are each proportional to frequency.

Column width: Each column corresponds to one level of the first variable (X). Width is proportional to the marginal frequency of that level: a wide column = frequent X-category, a narrow column = rare X-category. At a glance you see how the sample splits across X.

Segment height: Inside a column, each color is one level of the second variable (G). Height is proportional to the conditional probability P(G | X) — the share of that G-level within the X-level. When all columns share the same pattern (equal segment heights), X and G are independent.

Spotting independence: The mosaic plot is a visual test for statistical independence. If the segment shares (heights) stay constant across all X-columns, then P(G | X) = P(G) for every X — the two variables are independent. A segment that deviates strongly in one column reveals a relationship.

Typical Six-Sigma uses: complaint reason × sales region, defect type × shift, scrap class × machine. Where a stacked bar chart says "all columns look the same", the mosaic plot additionally reveals which X-categories are common in the first place.

Pitfalls

Too many categories: Beyond 5–6 X-categories the columns become so narrow that labels are hard to read. Group categories or filter to the most important ones. For too many G-categories the vertical color scale gets cluttered — keep it to ≈6 levels.

Small cells disappear: Very rare combinations (X_i, G_j) produce tiny rectangles that are easy to overlook. Cell labels (editor → "Show cell labels") place the count inside the rectangle when it is large enough. Still, check the stats table to read off exact counts.

Confusion with stacked bar: In a stacked bar chart every column has the same width; category differences only show in the segment heights. The mosaic plot, by contrast, encodes the marginal frequency in the width — a wide column is NOT "the same bar, just thicker" but a more frequent X.

Column order: Columns are laid out in the order of first observation in the worksheet. If a meaningful order is desired (e.g. by frequency or alphabetic), sort the column upfront or adjust the category order.

Causality: A visible relationship in the mosaic plot does NOT mean that X causes G (or vice versa) — it only shows dependence. For causal claims you need a designed experiment (DoE) or at least solid domain theory.

Examples

This module ships with the following example datasets — load any of them in the app with a single click.