Piechart





A piechart is a circle divided into sectors that each represent a proportion of the whole. It is highly criticized in dataviz for meaningful reasons (read more). This section teaches how to build one using R, using the pie() function or the ggplot2 package.

Warning

Piecharts are highly criticized in dataviz. Use it with care, or even better, use alternatives like barcharts, lollipop plots, treemap and others.

What's wrong with it? Barchart Lollipop



Step by step → the pie() function

The pie() function is natively provided in R. It allows to build nice piechart in seconds. Here is an overview of its functioning:





Step by step → the ggplot2 package

There is no specific geom to build piechart with ggplot2. The trick is to build a barplot and use coord_polar to make it circular. This is why the pie() function described above is probably a better alternative.

Related chart types


Grouped and Stacked barplot
Treemap
Doughnut
Pie chart
Dendrogram
Circular packing