[Tex/LaTex] Pie Chart – Problems with font size

pgf-pietikz-pgf

I am now working on a pie chart and i have a problem about the size of the number. Is there any way to make only the "1%" and "2%" smaller so that i can be seen clearly in the chart. (or make an arrow only on these two arcs)

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgf-pie}
\tikzset{lines/.style={draw=none},}
\tikzstyle{every node}=[font=\small]
\begin{document}
\begin{tikzpicture} 
    \pie[style={lines}, text=legend, rotate=220]{58/SHI, 5/General government, 13/Private households (OOP), 4/Employers, 9/PHI, 2/Statutory accident insurance, 1/Statutory Pension insurance, 8/Social long-term care insurance}

\end{tikzpicture}
\end{document}

enter image description here

Best Answer

look for the ".65" and change at will. The code is basically just copied from that package and changed in these few lines there.

\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgf-pie}
\usepackage{ifthen}
\tikzset{lines/.style={draw=none},}
\tikzstyle{every node}=[font=\small]

\makeatletter
% args:
% #1: begin angle
% #2: end angle
% #3: number
% #4: label
% #5: explode
% #6: fill color
% #7: radius
% #8: center
\def\pgfpie@slice#1#2#3#4#5#6#7#8{%
  \pgfmathparse{0.5*(#1)+0.5*(#2)}
  \let\pgfpie@midangle\pgfmathresult

  \path (#8) -- ++({\pgfpie@midangle}:{#5}) coordinate (pgfpie@O);

  \pgfmathparse{(#7)+(#5)}
  \let\pgfpie@radius\pgfmathresult

  % slice
  \draw[line join=round,fill={#6},\pgfpie@style] (pgfpie@O) -- ++({#1}:{#7}) arc ({#1}:{#2}:{#7}) -- cycle;

  \pgfmathparse{min(((#2)-(#1)-10)/110*(-0.3),0)}
  \pgfmathparse{(max(\pgfmathresult,-0.5) + 0.8)*(#7)}
  \let\pgfpie@innerpos\pgfmathresult

  \pgfpie@ifx\pgfpie@text\pgfpie@text@inside{%
    % label and number together
    \path (pgfpie@O) -- ++({\pgfpie@midangle}:{\pgfpie@innerpos}) node[align=center]
    {\pgfpie@scalefont{#3}\pgfpie@labeltext{#4}\\\pgfpie@numbertext{#3}};
  }{%
    % label
    \pgfpie@ifhidelabel{}{%
      \pgfpie@iflegend{}{%
        \path (pgfpie@O) -- ++ ({\pgfpie@midangle}:{\pgfpie@radius})
        node[inner sep=0, \pgfpie@text={\pgfpie@midangle:#4}]{};
      }%
    }%

    % number
    \path (pgfpie@O) -- ++({\pgfpie@midangle}:{\pgfpie@innerpos}) node
    {\ifthenelse{\equal{#3}{1}\OR\equal{#3}{2}}{%
            \scalebox{.65}{\pgfpie@scalefont{#3}\pgfpie@numbertext{#3}}%
        }{%
            \pgfpie@scalefont{#3}\pgfpie@numbertext{#3}%
        }%
    };
  }%
}
\makeatother

\begin{document}

\begin{tikzpicture}
    \pie[style={lines}, text=legend, rotate=220]{58/SHI, 5/General government, 13/Private households (OOP), 4/Employers, 9/PHI, 2/Statutory accident insurance, 1/Statutory Pension insurance, 8/Social long-term care insurance};
\end{tikzpicture}
\end{document}
Related Question