4

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

Daniel Chan
  • 191
  • 10
  • Maybe you can get a hint from https://tex.stackexchange.com/questions/338528/how-to-put-small-numbers-outside-the-pie-slices-without-making-a-mess?rq=1 – bmv Jan 24 '18 at 07:36
  • Perhaps consider moving the thin-sliced labels outside of the chart: https://tex.stackexchange.com/questions/595500/put-small-numbers-outside-of-a-pgf-pie-chart, https://tex.stackexchange.com/questions/594973/put-percentages-outside-of-pie-chart, https://tex.stackexchange.com/questions/320918/pie-graph-with-outside-text – Steven B. Segletes Jan 25 '22 at 01:13
  • Some unsolicited advice: pie charts are generally terrible (unless comparing pieces of pie). Just use a horizontal bar chart. – likethevegetable Jan 27 '22 at 03:00
  • just curious that how an user with 1 reputation can start a bounty ? – Black Mild Jan 27 '22 at 06:25

1 Answers1

1

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}

Peter Grill
  • 223,288