I really like the 'ring chart' or 'wheel chart' given as an example on page 88 of the PGF manual. It is like a pie chart, but with a label in the centre. Unfortunately, the manual doesn't give the source for that chart. Does anyone have an example? Thanks.

The graph

  • 1
    The PGF/TikZ-manual basically states in that section that pie charts (especially in 3D) and similar charts should be avoided in favor of tables or bar charts because they are clearer. This might be the reason no actual code is provided. However, you might want to check out the sources of the manual. Maybe you are lucky. May 10, 2011 at 16:53
  • 2
    @Martin: Directly below the graphic, the manual also states: [This] graphic has about the same information density as the table (about the same size and the same numbers are shown). In addition, one can directly “see” that there are more good or very good ratings than bad ones. One can also “see” that the number of people who gave no rating at all is not negligible, which is quite common for feedback forms.
    – Caramdir
    May 10, 2011 at 16:57
  • @Caramdir: Yes, indeed, it states there that they are good for things which add up to 100%. But AFAIK this types of charts are overused. May 10, 2011 at 17:02
  • 1
    Apropos pie charts: svott.com/mt/archives/pacman_piechart.jpg. May 10, 2011 at 17:02
  • @Martin Or this one: stats.stackexchange.com/questions/423/…
    – Sharpie
    May 10, 2011 at 17:06

2 Answers 2


I am afraid that this is drawn completely manually. The relevant code is in texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-guidelines.tex (in TeX Live 2010). For convenience it is also listed below (with a preamble added). Making a library out of this might be a useful project.



  \node[align=center,text width=3cm]{Ratings given by 50~participants};

  \begin{scope}[line width=4mm,rotate=270]
    \draw[good]          (-123:2cm) arc (-123:-101:2cm);
    \draw[good!60!white] (-36:2cm) arc (-36:-101:2cm);
    \draw[neutral]       (-36:2cm) arc (-36:36:2cm);
    \draw[bad!60!white]  (36:2cm)  arc (36:93:2cm);

    \foreach \angle in {0,72,...,3599}
      \divide\mycount by 10\relax
      \draw[black!15,thick] (\the\mycount:18mm) -- (\the\mycount:22mm);

    \draw (0:2.2cm) node[below] {``ok'': 10 (20\%)};
    \draw (165:2.2cm) node[above] {none: 20 (40\%)};
    \draw (-111:2.2cm) node[left] {``very good'': 3 (6\%)};
    \draw (-68:2.2cm) node[left] {``good'': 9 (18\%)};
    \draw (65:2.2cm) node[right] {``bad'': 8 (16\%)};
    \draw (93:2.2cm) node[right] {``very bad'': 0 (0\%)};
  \draw[gray] (0,0) circle (2.2cm) circle (1.8cm);

  • Beat me to it by a couple of seconds :P
    – Sharpie
    May 10, 2011 at 16:57
  • @Sharpie: I was just going to post it as well :-) Here the general CTAN link for that file: mirrors.ctan.org/graphics/pgf/base/doc/generic/pgf/text-en/… May 10, 2011 at 16:58
  • @Sharpie Beat me to. I've deleted mine as I didn't notice the "answer added" bar.
    – Edd
    May 10, 2011 at 17:01
  • Thanks to all - very useful. Yes, pie charts are over-used, but these are better than traditional ones for when there aren't many choices!
    – moabi2000
    May 11, 2011 at 17:50

Oooh, too tempting! Even though pie/wheel charts are bad, here's a macro to automatically draw the wheel chart from the PGF manual.

This command:

\wheelchart{20/green/good,  10/yellow/medium, 9/red/bad, 5/white/neutral}

Yields this chart:

Automatic wheel chart

Here's the implementation:


% Adjusts the size of the wheel:

% The main macro
    % Calculate total
    \foreach \value/\colour/\name in {#1} {

    % The text in the center of the wheel
      \node[align=center,text width=2*\innerradius]{Ratings given by \pgfmathprintnumber{\totalnum}~participants};

      % Calculate the thickness and the middle line of the wheel

      % Rotate so we start from the top
      \begin{scope}[line width=\wheelwidth,rotate=90]

      % Loop through each value set. \cumnum keeps track of where we are in the wheel
      \foreach \value/\colour/\name in {#1} {
            \pgfmathsetmacro{\newcumnum}{\cumnum + \value/\totalnum*360}

            % Calculate the percent value
            % Calculate the mid angle of the colour segments to place the labels

            % This is necessary for the labels to align nicely
                (-\midangle<85?"south west":
                  (-\midangle<175?"north west":
                    (-\midangle<265?"north east":
                      (-\midangle<355?"south east":"south")
            } \edef\textanchor{\pgfmathresult}

            % Draw the color segments. Somehow, the \midrow units got lost, so we add 'pt' at the end. Not nice...
            \draw[\colour] (-\cumnum:\midradius pt) arc (-\cumnum:-(\newcumnum):\midradius pt);

            % Draw the data labels
            \node at (\midangle:\outerradius + 1ex) [inner sep=0pt, outer sep=0pt, ,anchor=\textanchor]{\name: \value\ (\pgfmathprintnumber{\percentage}\%)};

            % The 'spokes'
            \foreach \i in {0,...,\value} {
                \draw [gray,thin] (-\cumnum-\i/\totalnum*360:\innerradius) -- (-\cumnum-\i/\totalnum*360:\outerradius);

            % Set the old cumulated angle to the new value

      \draw[gray] (0,0) circle (\outerradius) circle (\innerradius);

% Usage: \wheelchart{<value1>/<colour1>/<label1>, ...}
\wheelchart{20/green/good,  10/yellow/medium, 9/red/bad, 5/white/neutral}

  • Could you make a CTAN package out of it? Would easy usage for non-hardcore-IT-users :)
    – koppor
    Apr 21, 2012 at 18:35
  • I have issues with babel (pdflatex and lualatex) and polyglossia (xelatex) when using the package: pdflatex.exe> ! Undefined control sequence. pdflatex.exe> \wheelchart ...hsetmacro {\totalnum }{0} \foreach pdflatex.exe> \value /\colour /\name in ... pdflatex.exe> l.80 ...yellow/medium, 9/red/bad, 5/white/neutral} Could you try the code at your side with \usepackage[ngerman]{babel}?
    – koppor
    Apr 21, 2012 at 19:43
  • @koppor: This happens because : is made active by babel. It works if you set \catcode:=12\relax`.
    – Jake
    May 19, 2012 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.