I've gone through the answer in Package for pie charts.

Can you please suggest, how to give different color for each pie?


\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,fill=#5!30] (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/\c in {20/type A/red, 4/type B/blue, 11/type C/red,
                   49/type D/green, 16/other/yellow}
          {\p\%}{\t}{\c}  %% here we use the fifth variable



enter image description here


Just for fun with PSTricks.




    \pstVerb{/IA \thesum\space def /FA IA #2 add def}%
    \uput{1.5}[!IA FA add 2 div](0,0){\scriptsize #2\%}%
    \uput{3.2}[!IA FA add 2 div](0,0){#3}%

\Item{20}{type A}
\Item[blue]{4}{type B}
\Item{11}{type C}
\Item[green]{49}{type D}

enter image description here

  • 1
    My answer for another simpler question can be found here. – kiss my armpit Dec 23 '13 at 20:11

with chartColor=color you'll get the predefined colors instead of the user defined.


 \rput(psChartI1){type A}\rput[b](psChartI2){type B}
 \rput[t](psChartI3){type C}
 \rput(psChartI4){type D}\rput(psChartI5){other}

enter image description here

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.