2

I was wondering if there was a way to highlight a section of a pgfpie pie graph in a Beamer presentation.

One way I managed to make it work was to copy the entire figure, change the color of the desired section and use \only to first show the version with the original color, and then the version with the changed color, but that's quite an impractical way of doing it.

Here is a sample pgfpie graph:

\documentclass[14pt]{beamer}

\usepackage{pgf-pie}

\usepackage{siunitx}
\sisetup{
  output-decimal-marker={,},
  group-separator={\,},
}
\def\ScanPercentage#1\afternumber{\SI{#1}{\percent}}

% ---------------------------------------------------------------------------- %

\begin{document}
  \begin{frame}{Pie Chart}
    \begin{figure}
      \scriptsize
      \centering
      \begin{tikzpicture}
        \pie[color={blue, red}, rotate=-35, before number=\ScanPercentage, after  number ={ }\%,]{91.2/Muži, 8.8/Ženy}
      \end{tikzpicture}
    \end{figure}
  \end{frame}
\end{document}
1

Here is a solution using the multido package:

\documentclass[14pt]{beamer}

\usepackage{pgf-pie}
\usepackage{multido}

\usepackage{siunitx}
\sisetup{
  output-decimal-marker={,},
  group-separator={\,},
}
\def\ScanPercentage#1\afternumber{\SI{#1}{\percent}}

% ---------------------------------------------------------------------------- %

\begin{document}
  \begin{frame}{Pie Chart}
    \multido{\n=1+1}{2}{
      \only<\n>{
        \begin{figure}
          \scriptsize
          \centering
          \begin{tikzpicture}
            \pie[color={\ifnum\n=1 blue\else yellow\fi, red}, rotate=-35, before number=\ScanPercentage, after  number ={ }\%,]{91.2/Muži, 8.8/Ženy}
          \end{tikzpicture}
        \end{figure}
      }
    }
  \end{frame}
\end{document}

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.