[texhax] Drawing colored pie chart in KOMA-Class scrreprt (preferably without manually installing pgf-pie

Suresh Govindachar sgovindachar at yahoo.com
Sun Mar 23 00:22:24 CET 2014

> On Fri, Mar 21, 2014 at 5:02 PM, Pascal <pascal.bernhard at belug.de> asked:

[for a simple, quick way to add a 2-dimensional pie chart with colors 
without having to install pgf-pie]:

   > The first example works
   > (http://www.texample.net/tikz/examples/pie-chart/), but I'm
   > totally at a loss about how get colors into the pie chart.
   > This basically does the trick, I do not aspire to fancy stuff
   > like a drawn out slice, but colors I definitively would like
   > to see.
   > I should mention that in my case the pie chart is supposed to
   > show that the markets is carved up by two companies, one
   > having a 69 % market share, the other 29 %, which leaves 2 %
   > for various other tiny firms.  I'm not sure whether I could
   > modify the example above quite easily to fit my needs, so any
   > help here would also be higly appreciated.

Here's a simple tweak to that example to get colors and to illustrate 
your particular "69-29-2" example:

% Pie chart
% Original Author: Robert Vollmert
% Modified to illustrate coloring the slices by Suresh Govindachar


   % slice
   \draw[thick,fill=#5] (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/\c in
% original example with color added %   {20/type A/green!20!white,
% original example with color added %   4/type B/green!80!white,
% original example with color added %   11/type C/yellow!60!black,
% original example with color added %   49/type D/blue!40!white,
% original example with color added %   16/other/red!40!white}
% following is for OP's needs:
                   { 69/Big Company/green!80!black,
                     29/Start Up/blue!40!white,
                      2/Tiny Firms/yellow!30!white}

   From the TikZ document:  The color green!20!white means 20\%
   green and 80\% white mixed together. Such color expression are
   possible since TikZ uses Uwe Kern's xcolor package, see the
   documentation of that package for details on color expressions.


More information about the texhax mailing list