Contents

Pie Charts

This article continues the earlier LaTeX chart tutorials by focusing on pie charts and several related chart styles using the pgf-pie package.

Pie charts are commonly used to display proportions or comparisons. With pgf-pie, you can also create polar charts, cloud charts, and square charts from a similar syntax.

This article covers:

  1. standard pie charts
  2. polar charts (polar area charts)
  3. cloud charts
  4. square charts

Basic steps:

  1. open a LaTeX editor such as Overleaf
  2. use the article document class
  3. load the pgf-pie package
  4. draw the chart inside a tikzpicture environment

Basic example:

\documentclass{article}
\usepackage{pgf-pie}

\begin{document}
\begin{tikzpicture}
\pie[rotate=90]{25/GeoGebra, 20/Blogger, 15/Edmodo, 20/\LaTeX, 20/Moodle}
\end{tikzpicture}
\end{document}

Result:

Pie chart in LaTeX

In this example, rotate=90 changes the starting position of the chart by 90°.

In a polar chart, each sector has an angle and radius based on the represented value.

Use:

\pie[polar, explode=0.1, text=legend]{25/GeoGebra, 20/Blogger, 15/Edmodo, 20/\LaTeX, 20/Moodle}

Compiled result:

Polar chart in LaTeX

If you want the sectors to touch each other, remove explode. If you want the labels inside the sectors, use text=inside.

Example:

\pie[
  polar,
  rotate=270,
  text=inside,
  color={blue!55, green!60, red!70, yellow!50, magenta!60}
]{25/GeoGebra, 20/Blogger, 15/Edmodo, 20/\LaTeX, 20/Moodle}

Result:

Colored polar chart in LaTeX

A cloud chart draws a set of disks whose sizes depend on the data values, with labels placed inside them.

Code:

\pie[cloud, text=inside, scale font, radius=3]{25/GeoGebra, 20/Blogger, 15/Edmodo, 20/\LaTeX, 20/Moodle}

Result:

Cloud chart in LaTeX

The package can also generate a square-style chart.

Code:

\pie[square, scale font, color={blue!65, red!65, green, yellow, cyan}]{25/GG, 20/Blogger, 15/Edmo, 20/\LaTeX, 20/Moodle}

Compiled result:

Square chart in LaTeX

With pgf-pie, creating statistical diagrams in LaTeX is fairly concise. You can adjust the rotation, colors, label positions, and chart type depending on the presentation you need.

Related Content