[Tex/LaTex] How to make one legend for two pie charts

pgf-pietikz-pgf

I am using the package pgf-pie and want to have two pie charts next to each other but using the same legend. How can I have the legend centered below the two charts?

Mini example:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgf-pie}
\begin{document}
\begin{center}
\begin{minipage}{.45\textwidth}
\begin{tikzpicture}
\tikzset{lines/.style={draw=white},}
\pie[color={viola, rosso, giallo, blu, verde},sum=auto, after number=,text=legend,every only number node/.style={text=black},style={lines}]{10/A,20/B,30/C,10/D}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{.45\textwidth}
\begin{tikzpicture}
\tikzset{lines/.style={draw=white},}
\pie[color={viola, rosso, giallo, blu, verde},sum=auto, after number=,text=legend,every only number node/.style={text=black},style={lines}]{10/A,20/B,30/C,10/D}
\end{tikzpicture}
\end{minipage}
\end{center}
\end{document}

This example plots two pie charts side by side but each with a single legend.

Best Answer

According pgf-pie documentation you can use pos option to place a pie inside a tikzpicture. You don't need minipage.

And also from examples, seems that a second parameter inside values list (10/A, 20/B) adds names to pie. If you don't want a second legend, write a values list with empty names. If the order is correct, the first legend will serve.

\documentclass[border=10pt]{standalone}
\usepackage{pgf-pie}
\begin{document}
\begin{tikzpicture}
\tikzset{lines/.style={draw=white},}
\pie[color={purple, red, yellow, blue, green},sum=auto, after number=,text=legend,every only number node/.style={text=black},style={lines}]{10/A,20/B,30/C,10/D}
\pie[pos={8,0},color={purple, red, yellow, blue, green},sum=auto, after number=,every only number node/.style={text=black},style={lines}]{10/,20/,30/,10/}
\end{tikzpicture}
\end{document}

enter image description here