[Tex/LaTex] How to plot stacked pie charts using LaTeX

tikz-pgf

I need to plot the following diagram:

data-chart

But how I do not know any of the packages

  • datatool,
  • PGF/TikZ,
  • PSTricks,
  • datapie.

I know how to do simple pie charts with datapie, but this one it a bit tricky.

Best Answer

Just for fun, a TikZ solution inspired by Jake's wheelchart:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}

% The main macro
% #1 - List of value/color pairs
% #2 - inner radius
% #3 - outer radius
\newcommand{\wheelchart}[3]{
    % Calculate total
    \pgfmathsetmacro{\totalnum}{0}
    \foreach \value/\colour in {#1} {
        \pgfmathparse{\value+\totalnum}
        \global\let\totalnum=\pgfmathresult
    }

    % Calculate the thickness and the middle line of the wheel
    \pgfmathsetmacro{\wheelwidth}{(#3)-(#2)}
    \pgfmathsetmacro{\midradius}{(#3+#2)/2}

    % Rotate so we start from the top
    \begin{scope}[rotate=90]
    % Loop through each value set. \cumnum keeps track of where we are in the wheel
        \pgfmathsetmacro{\cumnum}{0}
        \foreach \value/\colour in {#1} {
            \pgfmathsetmacro{\newcumnum}{\cumnum + \value/\totalnum*360}

      % Draw the color segments.
            \draw[fill=\colour] (-\cumnum:#2) arc (-\cumnum:-\newcumnum:#2)--(-\newcumnum:#3) arc (-\newcumnum:-\cumnum:#3)--cycle;

       % Set the old cumulated angle to the new value
            \global\let\cumnum=\newcumnum
      }
      \end{scope}
}

\begin{tikzpicture}

% Usage: \wheelchart{<value1>/<colour1>, ...}{inner radius}{outer radius}
\wheelchart{5/yellow!70,2/purple!70,8/green!70,23/blue!70}{.5cm}{2cm}

\wheelchart{25/brown!70, 60/blue!70}{3cm}{4.5cm}

\draw[thick] (0,0)--(90:5cm);
\draw[thick] (0,1.25cm)--++(0:3mm) node[right] {No};
\draw[thick] (0,3.75cm)--++(0:3mm) node[right] {Yes};

\begin{scope}[xshift=5cm]
\draw[line width=3mm,blue!70] (0,1) -- ++(0:3mm) node[right, black] {5 years};
\draw[line width=3mm,green!70] (0,.5) -- ++(0:3mm) node[right, black] {10 years};
\draw[line width=3mm,brown!70] (0,0) -- ++(0:3mm) node[right, black] {15 years};
\draw[line width=3mm,purple!70] (0,-.5) -- ++(0:3mm) node[right, black] {20 years};
\draw[line width=3mm,yellow!70] (0,-1) -- ++(0:3mm) node[right, black] {Over 25 years};

\node[anchor=west] at (-.5,-3) {Pie Slices show Count};
\node[anchor=west, align=center] at (-.5,3) {How many years\\ experience do you};
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here