Create a Basic Pie Chart
A pie chart divides a circle into slices proportional to category totals.
R Graphics · Pie and Donut Chart
Create pie, labeled, percentage, exploded-style, donut, and ggplot2 composition charts.
Pie and donut charts encode shares as angles and areas. Reserve them for a few clearly different categories; bar charts are usually more precise when values are similar.
A pie chart divides a circle into slices proportional to category totals.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
v<-c(A=35,B=25,C=22,D=18);pie(v,col=c("#1d4ed8","#60a5fa","#93c5fd","#dbeafe"),main="Composition")Direct slice labels identify categories without repeated legend lookup.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
v<-c(A=35,B=25,C=22,D=18);pie(v,labels=paste(names(v),v),col=hcl.colors(4,"Blues 3"))Percentage labels state the part-to-whole values explicitly.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
v<-c(A=35,B=25,C=22,D=18);labs<-paste0(names(v)," ",round(100*v/sum(v)),"%")
pie(v,labels=labs,col=hcl.colors(4,"Blues 3"))Clockwise ordering and start angle can place the most important slice predictably.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
v<-sort(c(A=35,B=25,C=22,D=18),decreasing=TRUE);pie(v,clockwise=TRUE,init.angle=90,col=hcl.colors(4,"Blues 3"))A donut chart uses a central opening while retaining the same angular encoding as a pie.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
v<-c(A=35,B=25,C=22,D=18);pie(v,col=hcl.colors(4,"Blues 3"),border="white");symbols(0,0,circles=.45,inches=FALSE,add=TRUE,bg="white",fg="white")A stacked bar transformed to polar coordinates produces a flexible donut chart.

Run the code, inspect how the visual encoding changes, and adapt the labels, scales, and styling to the analytical question rather than treating the defaults as fixed.
library(ggplot2)
d<-data.frame(group=LETTERS[1:4],value=c(35,25,22,18))
ggplot(d,aes(x=2,y=value,fill=group))+geom_col()+coord_polar(theta="y")+xlim(.5,2.5)+theme_void()