[Tex/LaTex] Pie Chart without labels in beamer using pgf-pie

beamerpgf-pie

EDIT The accepted answer completely solves my immediate problem, but for more detailed analysis of the underlying issue please refer to answer by cfr. Basically, pstricks and pdfTex don't mix well.

I have a beamer presentation with a lot of pie charts. I use pgf-pie package because it is easy and (mostly) does what I need. I have one particular pie-chart that should have no labels at all. I have tried adding

/tikz/nodes={text opacity=0,overlay}

to the code following advice found here.

Small pie-chart without any numbers or text

\documentclass{standalone}
\usepackage{pgf-pie}
\begin{document}

\begin{tikzpicture}
\pie [explode=0.1, color={blue!70, green!80, red, yellow} ,/tikz /nodes={text opacity=0,overlay}]{10/, 20/, 30/, 40/}
\end{tikzpicture}
\end{document}

Now, the strange thing is, the code works well in the example above (standalone class). However, it doesn't seem to do anything inside a beamer presentation, i.e. the labels still show. It seems that there is some sort of package conflict. How could I enable this to work in the beamer presentation? I know there are other ways to produce this but pgf-pie is quite handy otherwise.

\documentclass[12pt,compress]{beamer}
\usetheme{Warsaw}

\setbeamertemplate{navigation symbols}{}%remove navigation symbols
\setbeamercolor{alerted text}{fg=magenta}

%\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{wasysym}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{xcolor}
%\usepackage{iwona}
\usepackage{wrapfig}
\input{FactorTree}
\usepackage{pstricks}
\usetikzlibrary{matrix}
\usepackage{tkz-euclide}
\usetkzobj[all]
\usepackage{xlop}
\usepackage{tcolorbox}
\usepackage{pgfplots}
\usepackage{pgf-pie}
\usepackage[makeroom]{cancel}
\input{longdiv}

Pie Chart Without Labels

Best Answer

The command \pgfpie@slice defined in pgf-pie.sty to draw circular diagram

\newcommand{\pgfpie@slice}[8]{
  \pgfmathparse{0.5*(#1)+0.5*(#2)}
  \let\midangle\pgfmathresult

  \path (#8) -- ++(\midangle:#5) coordinate(O);

  \pgfmathparse{#7+#5}
  \let\radius\pgfmathresult

  % slice
  \draw[line join=round, fill=#6, \style] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;

  \pgfmathparse{min(((#2)-(#1)-10)/110*(-0.3),0)}
  \let\temp\pgfmathresult
  \pgfmathparse{(max(\temp,-0.5) + 0.8)*#7}
  \let\innerpos\pgfmathresult

  \ifthenelse{\equal{\pgfpie@text}{inside}}
  {
    % label and number together
    \path (O) -- ++(\midangle:\innerpos) node
    {\scalefont{#3}\shortstack{#4\\\beforenumber#3\afternumber}};
  }
  {
    % label
    \iflegend
    \else
    \path (O) -- ++ (\midangle:\radius)
    node[inner sep=0, \pgfpie@text=\midangle:#4]{};
    \fi

    % number
    \path (O) -- ++(\midangle:\innerpos) node
    {\scalefont{#3}\beforenumber#3\afternumber};
  }
}

Numbers inside circle are defined with argument #3 of the command \pgfpie@slice, you can for example modify the definition of \beforenumber and \afternumber to obtain a phantom like command to hide numbers

For this you can just add before number=\phantom and after number=

Code

\documentclass{beamer}
\usepackage{pgf-pie}
\usepackage{pstricks}

\begin{document}

\begin{frame}
\begin{tikzpicture}
\pie [explode=0.1,color={blue!70, green!80, red, yellow},before number=\phantom,after number=]
{10/, 20/, 30/, 40/}
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here