I like the pie chart from http://www.texample.net/tikz/examples/pie-chart/, but it's in grey color.

Then I found the modified version to add colors by "Sigur" here:How to give different color to each pie?

but still, I need to specify the color by name.

Is there anyway to incorporate colormap as here (by Ronny):How to use colors from a pgfplots colormap in own draw

    draw=mapped color!80!black, fill=mapped color!80!white}}
        \begin{axis}[hide axis,
            xmin=-2.5, xmax=2.5,
            ymin=-.5, ymax=.5,
            axis equal]
        \draw[ellC=0, rotate around={-20:(0,0)}] (0,0) ellipse (.5 and .25);
        \draw[ellC=50, rotate around={0:(1,0)}] (1,0) ellipse (.45 and .3);
        \draw[ellC=100, rotate around={20:(2,0)}] (2,0) ellipse (.4 and **strong text**.35);

into those pie chart example.

  • I think stefan's answer solves your problem
    – percusse
    Commented May 30, 2016 at 7:24

2 Answers 2


Adapting Stefan's code to Sigur's answer, a possible solution could be



        color of colormap={#1},

\newcommand{\slice}[5]{ %% use 5 arguments here

  % slice %% I changed !10 to !30 to get darker color
  % use the fifth argument #5 to pass the color  
  \draw[thick, mycolor={#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};


%% -------------- use the new variable \c to pass the color
\foreach \p/\t [evaluate=\p as \color using \p*25] in {20/type A, 4/type B, 11/type C, 49/type D, 16/other}
          {\p\%}{\t}{\color}  %% here we use the fifth variable



The color used in this case is comuputed with \p*25 where \p corresponds to the pie section. You'll have to decide which mapping to use.

enter image description here


The same with PSTricks. Run the example with xelatex or pdflatex --shell-escape <file>


    blue!40,cyan!40,magenta!60}]{ 20, 4, 11, 49, 16 }{1}{2.75}
\pgfforeach \iA/\iB/\iC in {1/20/A,2/4/B,3/11/C,4/49/D,5/16/E}{%


enter image description here

\psChart[options]{data}{list of marked elements}{radius}


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .