3

I want to align several pie charts of different sizes in one table. Specifically, I want that these pie charts are horizontally and vertically aligned such that the centers of the pie charts are on one horizontal and vertical line, respectively. So far I was not succesfull. Any ideas?

%
% Examples for pgf-pie, by Yuan Xu
%
% Based on the manual from:
% http://code.google.com/p/pgf-pie/
%
\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf-pie}

\begin{document}
\maketitle

\begin{table}[h!]
\centering
\begin{tabular}{m{2cm} c c}
\hline
& A & B \\ \hline

A                    & 
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*3,
color = {green, gray, red}, sum=auto]{1/, 5/, 1/} 
\end{tikzpicture}
\end{tabular}
\end{center}&

\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.25992104989,
color = {gray}, sum=auto]{2/} 
\end{tikzpicture}
\end{tabular}
\end{center}\\ 


B                    &
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.44224957031,
color = {gray}, sum=auto]{3/} 
\end{tikzpicture}
\end{tabular}
\end{center}&

\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.58740105197,
color = {gray, red}, sum=auto]{2/ , 2/} 
\end{tikzpicture}
\end{tabular}
\end{center}

\end{tabular}
\end{table}
\end{document}

Currently it looks like that:

enter image description here

It should look loke this:

enter image description here

4

With clipping to a specific area it works:

\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf-pie}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{M}[1]{>{\Centering}m{#1}}
\begin{document}

\begin{tabular}{c | M{2.5cm} | M{1.75cm} |}\hline
    & A & B \\ \hline
A   &   \frame{\begin{tikzpicture}\clip (0,0) circle (1cm);
            \pie[radius=0.3*3,
            color={green,gray,red},sum=auto]{1/,5/,1/} 
            \end{tikzpicture}}%
    &  \frame{\begin{tikzpicture}\clip (0,0) circle (0.5cm);
            \pie[radius=0.3*1.2599,color={gray},sum=auto]{2/}%
            \end{tikzpicture}}\\
B   &   \frame{\begin{tikzpicture}\clip (0,0) circle (1cm);
            \pie[radius = 0.3*1.442,
            color = {gray}, sum=auto]{3/} 
            \end{tikzpicture}}
    &   \frame{\begin{tikzpicture}\clip (0,0) circle (0.5cm);
            \pie[radius = 0.3*1.587,
            color = {gray, red}, sum=auto]{2/ , 2/} 
            \end{tikzpicture}}
    \end{tabular}

\end{document}

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.