Method · Statistics Library

Pie chart

A pie chart draws each category of one column as a slice of a circle whose angle is that category's share of the total (rows counted, or a value column added up), so it shows how one whole splits into a few parts.

Topic indexA reference reading outside the guided chapter sequence

Understand the idea

A pie chart answers one question: how is this one whole split up? Each category gets a slice, and the slice's angle is its share: a category holding a quarter of the total fills a quarter of the circle. KernelStats writes each slice's percentage and count on it, so you never have to judge the angles by eye.

Our eyes compare angles and areas badly. Slices of 23% and 26% look almost the same, slices that are not next to each other are hard to compare, and a pie with many slices turns into a puzzle. A bar chart puts every category on the same baseline, where small differences in length are easy to see. So a bar chart reads better when there are more than about six categories, when slices are close in size and the difference matters, when you want to compare the same categories across groups or years, or when the numbers are not parts of one whole (averages or rates).

A pie works when there are a few parts of one whole and the message is a simple share, such as 'about three quarters' or 'one in five'.

A slice is a share of this total, not a size. Two pies with different totals cannot be compared slice by slice: a big slice of a small group can be fewer people than a small slice of a large group. And a pie describes this sample only; it tests nothing.

Practitioner explanation

KernelStats counts the rows of each category, or adds up an optional value column (Amount to add up per slice) per category; blank categories are not counted, rows with a blank value are left out, and a negative value is refused. Slices start at 12 o'clock and run clockwise, largest first by default (equal totals keep the order of first appearance) or in data order, which suits ordered categories. Largest slices before Other (0 = no limit, otherwise at least 2) keeps that many slices and pools the rest into one gray Other slice drawn last, unless a single category would be pooled; the table lists Other's members. Donut changes only the drawing. Each slice is labeled with its percentage and count or sum; slices under 3% carry their numbers in the table and on hover. The card warns from eight slices and refuses more than 30.

The percentages are 100 times each slice's total over the grand total (R: 100 * prop.table(table(x)), or the per-category sums of the value column). Cleveland and McGill's graphical-perception experiments (1984) ranked judgments of angle and area well below judgments of position along a common scale, which is why a bar chart, or a Cleveland dot plot of the counts (Dot Plot, Show set to count or sum), is the better default whenever categories are to be compared rather than read as shares of one whole.

When to use it

Consider it when

A few categories (up to about six) that are parts of one whole, when the message is each part's share: the sample by species, sales by product line, defects by type.

Use caution when

Many categories, slices close in size where the difference matters, the same categories compared across groups or over time, or numbers that are not parts of one whole (means, rates, overlapping percentages): use a bar chart. A pie is also not a test of whether the shares differ from expected ones.

Formulas and symbols

Share of each slice

percenti=100 Ti∑jTj\text{percent}_i = 100\,\dfrac{T_i}{\sum_j T_j}

T_i the number of rows in category i, or the sum of the value column over those rows; the slice's angle is 3.6 degrees per percent.

Alternatives

  • Bar Chart (Bar Chart). More than about six categories, slices close in size, a comparison across groups or years, or values that are not parts of one whole.
  • Dot Plot (Dot Plot), Show set to count or sum. Many categories to rank on one scale, sorted largest first, with the exact value of each easy to read.
  • Chi-Square Goodness-of-Fit Test (Chi-Square Goodness-of-Fit Test). You want to test whether the shares differ from equal shares or from shares you expected.

Worked example

Scenario

Pie chart of species in the penguins sample (344 rows, counting rows, largest first).

Result

Adelie 152 (44.2%), Gentoo 124 (36.0%), Chinstrap 68 (19.8%); the largest slice is Adelie.

Interpretation

Adelie make up a little under half of this sample and Chinstrap about one in five. These are shares of these 344 birds, not of the wild populations, and the chart tests nothing.

Dataset: penguins.csv

Common misconceptions

Misconception

This slice looks bigger than that one, so that category is bigger.

Correction

Angles and areas are judged poorly, above all for slices that are close in size or not next to each other. Read the printed percentages, or draw a bar chart when the comparison matters.

Misconception

The slice for this category is bigger in this year's pie than in last year's, so there are more of them this year.

Correction

A slice is a share of its own pie's total. If the totals differ, a larger share can be fewer rows. Compare the counts, or put both years on one bar chart.

Misconception

The pie shows that the categories really differ in how common they are.

Correction

A pie describes this sample. Whether the shares differ from expected shares by more than chance would give is a question for the Chi-Square Goodness-of-Fit Test.

References

  1. Graphical perception: theory, experimentation, and application to the development of graphical methods, Cleveland, W. S. and McGill, R. (1984), Journal of the American Statistical Association, 79(387), 531-554.