5

Is possible to change text color inside pie chart using the pgf-pie package?

Is possible change the color of text on a single slice of the 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}
  • You could try \textcolor{enter color here}{your text here} if the text you are talking about is in a node. – dustin Aug 14 '13 at 14:11
  • Hi Dustin unfortunately your suggestion doesn't work with this package "pgf-pie" – user21431 Aug 15 '13 at 10:55
  • I can't find any documentation on this package so I don't know how you can do that. My first comment was a guess. – dustin Aug 15 '13 at 17:02
  • While I'm not an expert, it doesn't appear to be possible at the moment without editing pgf-pie.sty somehow, so I would suggest placing a feature request in the issue tracker. – Torbjørn T. Aug 18 '13 at 8:22
  • How can I do this by editing the file pgf-pie.sty ? – user21431 Aug 18 '13 at 20:45
8
+50

I can’t really recommend pgf-pie due its inflexibility (and its use of the main PGFkeys path) but here is a etoolbox powered solution to insert a key that is tried on the node that includes the number (and only that number).

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

Output

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.