Skip to main content
v2026.11,986 entries · CC-BY 4.0

ggplot Piechart: coord_polar() Recipe, Labels and Alternatives

How to make a ggplot piechart with coord_polar(theta = “y”): stacked-bar recipe, labels, arguments explained, troubleshooting and free alternatives.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

A ggplot piechart is not a dedicated geom. In ggplot2 you draw a single stacked bar and then bend it into a circle with coord_polar(theta = "y"). The ggplot2 reference states it directly: “The polar coordinate system is most commonly used for pie charts, which are a stacked bar chart in polar coordinates.” This guide gives the working recipe, explains each argument, and shows what to do when the output looks wrong.

What it is used for in research

A pie chart shows how one whole divides into parts, for example the share of participants in each study arm or the share of records in each publication type. Two official R sources urge caution before you use one. The ggplot2 reference warns: “Use these plots with caution – polar coordinates has major perceptual problems.” The base R documentation for pie() says: “Pie charts are a very bad way of displaying information. The eye is good at judging linear measures and bad at judging relative areas. A bar chart or dot chart is a preferable way of displaying this type of data.”

Use a pie only when the audience needs a quick sense of one part against the whole and you have a handful of categories. For comparing categories with each other, see the guide to a bar plot in R. For the wider question of which chart fits which data, see types of graphs in statistics.

Install or access (official source only)

ggplot2 is distributed on CRAN, R’s package repository. The CRAN package page (checked 2026-10-29) lists version 4.0.3, which depends on R 4.1 or later. Install and load it from the R console:

install.packages("ggplot2")
library(ggplot2)

Step-by-step: build a pie chart with coord_polar()

The data below are illustrative values that sum to 100, chosen so the labels read as percentages. Replace them with your own.

  1. Create a data frame with one row per slice: a category column and a value column.
    df <- data.frame(
      group = c("A", "B", "C"),
      n     = c(50, 30, 20)
    )
  2. Draw one stacked bar of width 1. Put a constant in x, map the category to fill, and use geom_col(width = 1) so the bar fills its whole slot. This mirrors the official example, which uses aes(x = factor(1), fill = factor(cyl)) with geom_bar(width = 1).
    p <- ggplot(df, aes(x = "", y = n, fill = group)) +
      geom_col(width = 1)
  3. Bend the bar into a circle. Map the angle to the value axis with theta = "y".
    p + coord_polar(theta = "y")
  4. Remove the axes and grid with theme_void(), which the ggplot2 reference describes as “a completely empty theme”.
    p + coord_polar(theta = "y") + theme_void()
  5. Add labels inside the slices. The geom_text() reference explains that to place text in the middle of each bar in a stacked bar plot you set vjust in position_stack(); position_stack(vjust = 0.5) centres each label in its segment.
    p +
      geom_text(aes(label = paste0(n, "%")),
                position = position_stack(vjust = 0.5)) +
      coord_polar(theta = "y") +
      theme_void()
  6. Set the colours if the default palette does not suit. scale_fill_brewer(palette = "Set1") applies a ColorBrewer palette to the fill; see colours in R and RStudio for more on choosing them.

Titles and legend text work as in any ggplot2 chart; see the guides to ggplot titles and ggplot legend labels.

Output and how to read it

Each slice’s angle is its share of the stacked total, so the slice for group A above covers half the circle. coord_polar() takes these arguments, as documented in the ggplot2 reference (checked 2026-10-29):

Argument Default What it does (from the reference)
theta "x" The variable to map angle to, x or y. A pie needs "y" here.
start 0 Offset of the starting point from 12 o’clock, in radians.
direction 1 1 is clockwise, -1 is anticlockwise.
clip "on" Whether drawing is clipped to the plotting panel.

Because start is in radians, a quarter turn is pi / 2. Compare slices by angle only roughly: the warnings quoted above exist because readers judge angles and areas less accurately than lengths on a common scale. If the exact values matter, print them on the slices or use a bar chart.

Troubleshooting

Symptom Likely cause and fix
You get concentric rings instead of slices The default is theta = "x", which the reference calls a “bullseye”. Add theta = "y" to coord_polar().
The pie is a single colour with no slices No variable is mapped to fill. Add fill = group (your category column) inside aes().
Slices run the wrong way round the circle Set direction = -1 for anticlockwise.
The first slice starts in the wrong place Set start in radians, measured from 12 o’clock.
Axis text and a grey grid surround the pie Add theme_void().
Labels sit at the slice edge, not the middle Pass position = position_stack(vjust = 0.5) to geom_text().

Free alternatives

Option How Source
Base R pie chart pie(x, labels = names(x)), where x is a vector of non-negative numbers shown as slice areas. Its clockwise and init.angle arguments set direction and start. R graphics::pie documentation
Bar chart The R documentation names a bar chart as the preferable display. See bar plot in R. R graphics::pie documentation, Note section
Dot chart Also named in the same note as preferable, because position along a common scale is judged more accurately than angle. R graphics::pie documentation, Note section

For examples of charts that mislead and what to do instead, see bad data visualization examples.

FAQ

How do I make a pie chart in ggplot2?

Draw a stacked bar of width 1 with the category mapped to fill, then add coord_polar(theta = "y"). The ggplot2 reference describes a pie chart as a stacked bar chart in polar coordinates.

How do I change where the pie starts or which way it runs?

Use the start argument (an offset from 12 o’clock in radians) and direction (1 clockwise, -1 anticlockwise) in coord_polar().

Should I use a pie chart or a bar chart?

Both the ggplot2 and base R documentation caution against pie charts. The R documentation calls a bar chart or dot chart preferable, so reserve pies for a few categories where part-to-whole is the point.

Sources (official docs)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about ggplot Piechart: coord_polar() Recipe, Labels and Alternatives

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →