饼图 - 字体大小问题

饼图 - 字体大小问题

我现在正在制作饼图,但数字大小有问题。有没有办法只让“1%”和“2%”变小,以便在图表中清晰可见。(或者只在这两个圆弧上画一个箭头)

\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}

在此处输入图片描述

答案1

找到“.65”并随意更改。代码基本上只是从该包中复制并在那里的几行中进行更改。

\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}

相关内容