Get Started →
Composition CategoricalProportional

Pie Chart

ggplot2: geom_col() + coord_polar("y") · Package: ggplot2 · Variables: 1 categorical + 1 numerical

WHAT IS A PIE CHART?

A pie chart divides a circle into slices where each slice represents a proportion of the whole. Despite controversy in the data visualization community, pie charts remain effective for simple part-to-whole relationships with 2-5 categories — especially when one category clearly dominates. They answer "what fraction of the total does each category represent?" Avoid pie charts with more than 6 slices or when comparing similarly-sized segments (humans are poor at comparing angles). For many categories, use a treemap or bar chart instead. In ggplot2, pie charts use coord_polar("y") applied to geom_col().

BEST FOR

  • · Simple part-to-whole (2-5 slices)
  • · Highlighting a dominant category
  • · Rough proportions

AVOID WHEN

  • · More than 6 categories
  • · Comparing similar-sized slices
  • · Values not summing to a whole
  • · Precise comparison needed

R + GGPLOT2 CODE EXAMPLE

ggplot2
df <- data.frame(cyl = c("4", "6", "8"), n = c(11, 7, 14))
ggplot(df, aes(x = "", y = n, fill = cyl)) +
  geom_col(width = 1) +
  coord_polar(theta = "y") +
  theme_void() +
  labs(title = "Cars by Cylinder", fill = "Cylinders")

Run this code now

Paste the code above into RChat and see the pie chart rendered instantly in your browser.

Try RChat Free →

SIMILAR CHART TYPES

ALTERNATIVES FOR YOUR DATA TYPE