Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to create a pie chart in LaTeX. Do you know a package which manages that? I tried datatool which uses tikz as backend but seems to be unusable due to mysterious floating point errors.

share|improve this question
I recommend asking about the problems with datatool. – Will Robertson Nov 21 '10 at 3:21
This is really a non-answer, so I’ll just add it as a comment: I strongly recommend not creating a pie chart at all; there are far better alternatives. See the article ‘Save the Pies for Dessert’ at for a thorough discussion. – Karl Ove Hufthammer Dec 14 '11 at 10:39
@KarlOveHufthammer A pie chart has two advantages: people like it and you can see with one glance whether the pieces of the pie add up to 100%. All other charts force me to start my own calculation, instead of listening to the speech. – Keks Dose May 21 '13 at 9:39
Related: – Bordaigorl May 26 '14 at 11:40

6 Answers 6

Use the package pgf-pie, which is not on CTAN, but on Google Code.

    \pie{10/A, 20/B, 30/C, 40/D}


Note however that there are conflicts with this package and any other package that introduces the command \text—e.g.: amstext. In order to mediate these effects edit pgf-pie.sty, replacing all occurrences of: \text with: \textASDF.

share|improve this answer
The latest version of the package doesn't seem to redefine \text. – Torbjørn T. Nov 21 '12 at 7:05
This is a great package! The manual is really clear and easy. What a pity that this package is not on CTAN. – Keks Dose May 21 '13 at 9:42

There are several packages which master that.

The first one can generate charts from data files.

share|improve this answer

An piechart example with pgf/tikz from by Robert Vollmert is a good starting point. I'll just quote it here for completeness:

% Pie chart
% Author: Robert Vollmert


  % slice
  \draw[thick,fill=black!10] (0,0) -- (#1:1) arc (#1:#2:1) -- cycle;

  % outer label
  \node[label=\midangle:#4] at (\midangle:1) {};

  % inner label
  \pgfmathparse{max(\temp,-0.5) + 0.8}
  \node at (\midangle:\innerpos) {#3};


\foreach \p/\t in {20/type A, 4/type B, 11/type C,
                   49/type D, 16/other}



which looks like
enter image description here

share|improve this answer
This is a good start. I would like to be able to enter 49.5 instead of 49 percent as well as be able to set the colors. – The Dude Sep 30 '11 at 17:07

Here's an example taken from the datatool manual:






\caption{A pie chart}


enter image description here

share|improve this answer

Run with xelatex



\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}


enter image description here

share|improve this answer

High and simply customizable, percent and angle totals correctible.

enter image description here




        dc tag/.style={align=center},
        dc legend/.style={align=left,anchor=west},
        dc sector/.style={fill=\Cj,line join=round}

        % liste of \Name/Value
        value list/.store in=\Value@list,
        % circular : 360 - semi circular 180
        angle max/.store in=\Angle@max,
        angle max=360,
        % radius of the diagram
        radius/.store in=\R@dius,
        % composition of the legend
        % \V value
        % \N name
        % \P percent
        % \A angle
        % \Cj color
        legend/.store in=\L@gend,
        % location of the legend
        legend location/.store in=\Legend@Loc,
        legend location={($(\R@dius,\R@dius)+(.5,-.5)$)},   
        % poisition of the node in the sector
        % 0 center, 1 on the edge, 1.++ external
        factor/.store in=\F@ctor,
        % composition of the node in the sector
        tags/.store in=\T@gs,
        % correction of round errors in percents
        percent corr/.store in=\C@rrP,
        percent corr=,
        % correction of round errors in angles
        angle corr/.store in=\C@rrA,
        angle corr=,
        % individual shift
        shift sector/.store in=\Shift@j,
        shift sector=,
        % more nodes in the sectors, or new legeng
        sup loop/.store in=\Sup@Loop,
        sup loop=,
        % code of the diagram
        % Calculation of the sum
        \foreach \i/\y in \Value@list {\xdef\S@m{\S@m+\i}}  

        % beginning of the first sector

        % main loop
        \foreach \V/\N [count=\j from 0] in \Value@list {%

        % calculation of the current angle

        % superior limit of the sector
        \pgfmathsetmacro\@ngleB{\@ngleA+\A} ;

        % mean angle
        \pgfmathsetmacro\MedA{(\@ngleA+\@ngleB)/2} ;        

        % color

        % individual shift

        % drawing of the sector
        \draw[dc sector,shift={(\MedA:\Sh@ft)}] (0,0)
            -- (\@ngleA:\R@dius) arc (\@ngleA:\@ngleB:\R@dius)
                node[midway] (DC\j) {} -- cycle ;

        % low limit of the next sector
        \xdef\@ngleA{\@ngleB} ;

        % current percent correction

        % current angle and corection

        % the sector node
        \DiagNode[dc tag]{\F@ctor} {\T@gs} ;

        % the legend
        \draw[fill=\Cj] (0,-.5*\j)
                rectangle ++(.25,.25) ++(0,-.15)
                node[dc legend] {\strut\L@gend} ;

        % some more stuff
        \Sup@Loop ;

        } % end of diagram code

% Node on the \j sector
\newcommand{\DiagNode}[2][]{\node[#1] at ($(0,0)!#2!(DC\j)$)}


    % style options
    dc tag/.append style={font=\bfseries\small},
    % diagram options
    value list={149/A,1236/R+L+D,740/N+F,346/C},
    angle max=180,             % semi-circular
    tags=\N\\\P,                   % custom sector nodes
    diagram] ;



    % style options
    dc sector/.append style={shift={(\MedA:5pt)}}, % shift all sectors
    dc dtag/.append style={},
    dc legend/.append style={text width=2cm, align=right},
    every pin/.style={fill=\Cj,draw=\Cj!50!black,thick},
    % diagram options
    value list={149/A,1236/R+L+D,740/N+F,346/C,75/E},
    angle max=180,             % semi-circular
    angle corr={0,1,0,0,0},    % correct round angle error
    legend=\N\ :\hfill \V,     % custom legend
    percent corr={0,-1,0,0,0}, % correct round percent error
    shift sector={0,0,.3,0,0}, % shift individual sector
    tags=\P,                   % custom sector nodes
    sup loop={% custom features :       
        %\DiagNode{1.1} {\N};  % some other sector nodes
        % or something else
        \node[pin=\Pinj:\A] at (DC\j) {}  ;
    diagram] ;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.