Q&A 30 How do you visualize simple proportions using a pie chart?

30.1 Explanation

A pie chart represents parts of a whole as slices of a circle. Each slice’s size is proportional to its value, making it easy to visualize category proportions at a glance.

  • Best used when comparing a small number of categories (≀5)
  • Labels or percentages should be clearly shown
  • Not ideal for precise comparisons β€” bar charts are usually better

Use pie charts in: - Survey responses (e.g., favorite colors, device usage) - Market share or budget composition - Simple storytelling visuals

30.2 Python Code

import pandas as pd
import matplotlib.pyplot as plt

data = pd.Series([40, 30, 20, 10], index=["A", "B", "C", "D"])
plt.figure(figsize=(5, 5))
data.plot.pie(autopct='%1.1f%%', startangle=90)
plt.title("Category Proportions")
plt.ylabel("")
plt.tight_layout()
plt.show()

30.3 R Code

data <- c(A = 40, B = 30, C = 20, D = 10)
pie(data, main = "Category Proportions", col = rainbow(length(data)))

βœ… Pie charts are best used when showing a few categories and emphasizing part-to-whole relationships in a visually simple way.