如何给饼图增添趣味?

如何给饼图增添趣味?

饼图:

\documentclass{article}

\usepackage{calc} 
\usepackage{ifthen} 
\usepackage{tikz}
\begin{document} 
\newcommand{\slice}[5]{ %% use 5 arguments here   
\pgfmathparse{0.5*#1+0.5*#2}   
\let\midangle\pgfmathresult

% 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{min((#2-#1-10)/110*(-0.3),0)}  
\let\temp\pgfmathresult   
\pgfmathparse{max(\temp,-0.5) + 0.8}  
\let\innerpos\pgfmathresult   
\node at (\midangle:\innerpos) {#3}; }

\begin{tikzpicture}[scale=3]

\newcounter{a} \newcounter{b} 
%% -------------- 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}   {
    \setcounter{a}{\value{b}}
    \addtocounter{b}{\p}
    \slice{\thea/100*360}
           {\theb/100*360}
           {\p\%}{\t}{\c}  %% here we use the fifth variable 
           }

\end{tikzpicture}

\end{document}

但如何才能让它看起来更棒一些,让它更引人注目呢?

相关内容