TExcelTAD
Home › Statistics › Pie Charts

Pie Charts

A pie chart shows how a whole is split into parts. Each category gets a slice whose angle is proportional to its share: a category with relative frequency f / n gets 360° × f / n of the circle.

Pie charts work well when:

  • the data is categorical,
  • the parts add up to a meaningful whole (100% of something),
  • there are only a few categories (about 2–6),
  • you want to show part-to-whole relationships ("almost half of our users are on mobile").

They work badly when slices are similar in size, when there are many categories, or when you need to compare several pies. Humans judge angles and areas much less precisely than lengths, which is why a bar chart is often the better choice.

From frequencies to angles

A small streaming service asked 200 subscribers which device they mostly watch on:

python · try it yourself
devices = {"TV": 92, "phone": 54, "laptop": 38, "tablet": 16}
total = sum(devices.values())

print(f"{'device':8s} {'f':>4s} {'share':>7s} {'angle':>7s}")
for name, f in devices.items():
    share = f / total
    print(f"{name:8s} {f:4d} {share:7.1%} {360 * share:6.1f}°")
print("angles add up to", round(sum(360 * f / total for f in devices.values()), 1))
device      f   share   angle
TV         92   46.0%  165.6°
phone      54   27.0%   97.2°
laptop     38   19.0%   68.4°
tablet     16    8.0%   28.8°
angles add up to 360.0

Drawing a pie chart

python · try it yourself
import matplotlib.pyplot as plt

devices = ["TV", "phone", "laptop", "tablet"]
viewers = [92, 54, 38, 16]
colors = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100"]

fig, ax = plt.subplots(figsize=(4.5, 4.5))
ax.pie(viewers, labels=devices, colors=colors, autopct="%1.0f%%",
       startangle=90, counterclock=False,
       wedgeprops={"edgecolor": "white", "linewidth": 2})
ax.set_title("Main viewing device (n = 200)")
plt.tight_layout()
plt.show()
print("Pie chart with", len(devices), "slices")
Pie chart with 4 slices
  • autopct prints each slice's percentage.
  • startangle=90, counterclock=False starts at 12 o'clock and goes clockwise, the order most readers expect.
  • A white edge between slices keeps neighbouring colours apart.

Too many slices? Group the small ones

With many small categories, combine the smallest into "Other" so the chart stays readable:

python · try it yourself
import pandas as pd

languages = pd.Series({"English": 412, "Spanish": 133, "French": 61, "German": 38,
                       "Italian": 21, "Dutch": 12, "Polish": 9, "Greek": 6})
share = languages / languages.sum()

main = languages[share >= 0.05]
grouped = pd.concat([main, pd.Series({"Other": languages[share < 0.05].sum()})])
print((grouped / grouped.sum()).round(3))
English    0.595
Spanish    0.192
French     0.088
German     0.055
Other      0.069
dtype: float64

Eight slices became five, and the "Other" slice still keeps the total honest.

Pie or bar? A side-by-side comparison

When the parts are close in size, try to rank the slices of the pie below, then check the bars:

python · try it yourself
import matplotlib.pyplot as plt

teams = ["A", "B", "C", "D", "E"]
votes = [21, 19, 22, 18, 20]
colors = ["#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4"]

fig, (pie_ax, bar_ax) = plt.subplots(1, 2, figsize=(9, 3.5))
pie_ax.pie(votes, labels=teams, colors=colors, startangle=90, counterclock=False,
           wedgeprops={"edgecolor": "white", "linewidth": 2})
pie_ax.set_title("hard to rank")
bar_ax.bar(teams, votes, color="#2a78d6", width=0.6)
bar_ax.set_title("easy to rank")
fig.tight_layout()
plt.show()
print("ranking:", sorted(teams, key=lambda t: votes[teams.index(t)], reverse=True))
ranking: ['C', 'A', 'E', 'B', 'D']

The slices look almost identical, but the bars immediately reveal that team C leads and team D trails.

Tip: Avoid 3D pies, exploded slices and pies of data that doesn't add up to a whole (e.g. "% of respondents who mentioned each feature" when people could pick several). Each of these distorts the reader's sense of proportion.

Test yourself

A category makes up 15% of the data. How large is its slice?

  1. 15°
  2. 36°
  3. 54°
  4. 90°

Which data is suitable for a pie chart?

  1. Daily temperatures over a month
  2. Share of a budget spent on 4 departments
  3. Heights of 300 students
  4. Survey where respondents could choose several answers

Why are bar charts often preferred over pie charts?

  1. Bars use less ink
  2. People compare lengths more accurately than angles or areas
  3. Pies can't show percentages
  4. Bars work only for categorical data