是否可以使用 pgf-pie 包更改饼图内的文本颜色?
是否可以改变饼图中单个切片上的文字颜色?
\documentclass[tikz]{standalone}
\usepackage{pgf-pie}
\begin{document}
\begin{tikzpicture}[scale=0.9]
\pie[
/tikz/every pin/.style={align=center},
text=pin,
rotate=240,
explode=0.2,
color={blue!70,cyan!70,red!70,orange!50}
] {65/Amplificatori di\\potenza, 10/Elaborazione\\del segnale,
17.5/Sistemi di\\raffreddamento, 7.5/Alimentazione}
\end{tikzpicture}
\end{document}
答案1
我不推荐它,pgf-pie
因为它不够灵活(而且使用了主 PGFkeys 路径),但这里有一个etoolbox
供电解决方案插入在包含该号码(且仅包含该号码)的节点上尝试的密钥。
\documentclass[tikz]{standalone}
\usepackage{pgf-pie,etoolbox}
\makeatletter
\patchcmd\pgfpie@slice
{node {\scalefont{#3}\beforenumber#3\afternumber}}
{node[/every only number node/.try] {\scalefont{#3}\beforenumber#3\afternumber}}{}{}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=0.9]
\pie[
/tikz/every pin/.style={align=center},
every only number node/.style={text=white},
text=pin,
rotate=240,
explode=0.2,
color={blue!70,cyan!70,red!70,orange!50}
] {65/Amplificatori di\\potenza, 10/Elaborazione\\del segnale,17.5/Sistemi di\\raffreddamento, 7.5/Alimentazione}
\end{tikzpicture}
\end{document}
输出
答案2
/tikz/nodes={text=white, font=\bfseries, ...... },
\documentclass[tikz, border=5pt]{standalone}
\usepackage{pgf-pie}
\begin{document}
\begin{tikzpicture}[scale=0.9]
\pie[
/tikz/nodes={text=white, font=\bfseries},
/tikz/every pin/.style={align=center, text=black, font=\normalfont},
text=pin,
rotate=240,
explode=0.2,
color={blue!70,cyan!70,red!70,orange!50}
] {65/Amplificatori di\\potenza, 10/Elaborazione\\del segnale,
17.5/Sistemi di\\raffreddamento, 7.5/Alimentazione}
\end{tikzpicture}
\end{document}