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

1 Answer 1

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

4
  • Thank you. Do you have suggestions how to solve this problem?
    – FeldO
    Commented May 30, 2019 at 13:39
  • might be related: mysterious margins drawing TikZ arcs
    – ebosi
    Commented May 30, 2019 at 13:56
  • @FeldO: see edited answer
    – user187802
    Commented May 30, 2019 at 14:27
  • Perfect, it works!
    – FeldO
    Commented May 30, 2019 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .