[Tex/LaTex] How to add a legend to a pgfgantt chart using the \node command

pgfgantt

I am referring to the answer of Alain Matthes to a question asked some time ago.

What I have is a gantt chart which shows the steps in a project. I am pretty much finished with it and I really like the chart design but I have one big issue: I need to add a legend to this chart.

What I found in the question mentioned above is the \node command.

So I tried this for hours now but I can't seem to get the solution Alain Matthes suggested working. Please read his answer before continuing.
I want to have about 5 boxes inside the chart in the upper right. But all I get is 5 boxes that are slightly above and right from the previous box. What I tried was something like this:

\documentclass[12pt]{article}
\usepackage{pgfgantt}
\begin{document}
\begin{center}
\begin{figure}[H]
\noindent\resizebox{480pt}{!}{
\begin{tikzpicture}
\begin{ganttchart}
[
vgrid,
vgrid style/.style=dotted,
hgrid,
hgrid style/.style=dotted,
y unit title=0.5cm,
y unit chart=0.8cm,
title/.append style={shape=rectangle, fill=black!20},
title height=1,
bar/.append style={fill=blue!80},
bar height=.5,
bar label font=\normalsize\color{black!80},
group top shift=.6,
group height=.3,
group peaks height=.2,
]
{1}{35}
\gantttitle{Some Title}{35}\\\\
\gantttitlelist{1,...,35}{1}\\\\
\gantttitle{Plan}{7}\gantttitle{Execute}{11}\gantttitle{Stabilize}{4}\gantttitle{Finish}{13}\\

\ganttgroup{Plan}{1}{6}\\
\ganttbar[name=kickoff1]{Kick-Off Meeting}{1}{1}\\
%This looks like the result I want but in the wrong place:
\node[fill=blue,draw] at ([yshift=-20pt]current bounding box.south){Person A};
\node[fill=yellow,draw] at ([yshift=-20pt]current bounding box.south){Person B};
\node[fill=green,draw] at ([yshift=-20pt]current bounding box.south){Person C};
\node[fill=red,draw] at ([yshift=-20pt]current bounding box.south){Person D};
\node[fill=purple,draw] at ([yshift=-20pt]current bounding box.south){Person E};
%This is where I want it to be but arranged as above:
\node[fill=blue,draw] at ([yshift=-20pt]current bounding box.north east){Person A};
\node[fill=yellow,draw] at ([yshift=-20pt]current bounding box.north east){Person B};
\node[fill=green,draw] at ([yshift=-20pt]current bounding box.north east){Person C};
\node[fill=red,draw] at ([yshift=-20pt]current bounding box.north east){Person D};
\node[fill=purple,draw] at ([yshift=-20pt]current bounding box.north east){Person E};
\end{ganttchart}
\end{tikzpicture}
}
\end{figure}
\end{center}
\end{document}

I assume this is a really silly mistake but even after reading the official documentation of pgfgantt, I cant happen to understand how to place this boxes properly. Any help is highly appreciated as I am about to bite chunks out of my desk..

Thanks in advance!

The following code is based on answer from cfr and solves the problem described above perfectly:

\documentclass[12pt]{article}
\usepackage{pgfgantt}
\begin{document}
\begin{center}
\begin{figure}[H]
\noindent\resizebox{480pt}{!}{
\begin{tikzpicture}
\begin{ganttchart}
[
vgrid,
vgrid style/.style=dotted,
hgrid,
hgrid style/.style=dotted,
y unit title=0.5cm,
y unit chart=0.8cm,
title/.append style={shape=rectangle, fill=black!20},
title height=1,
bar/.append style={fill=blue!80},
bar height=.5,
bar label font=\normalsize\color{black!80},
group top shift=.6,
group height=.3,
group peaks height=.2,
]
{1}{35}
\gantttitle{Some Title}{35}\\\\
\gantttitlelist{1,...,35}{1}\\\\
\gantttitle{Plan}{7}\gantttitle{Execute}{11}\gantttitle{Stabilize}{4}\gantttitle{Finish}{13}\\
\ganttgroup{Plan}{1}{6}\\
\ganttbar{Kick-Off Meeting}{1}{1}\\
\ganttset{bar/.append style={fill=yellow!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=green!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=red!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=purple!80}}
\ganttbar{}{1}{1}\\
\ganttset{bar/.append style={fill=blue!80}}
\ganttlinkedbar{Current state}{2}{2}\\
\ganttlinkedbar{Define goals}{3}{4}\\
\ganttlinkedbar{Choose solution}{5}{6}\\
%This is the solution that works:
\node (a) [fill=blue,draw,anchor=east] at ([xshift=-40pt]current bounding box.8){Person A};
\node (b) [fill=yellow,draw,anchor=west] at ([yshift=-20pt]a.south west){Person B};
\node (c) [fill=green,draw,anchor=west] at ([yshift=-20pt]b.south west){Person C};
\node (d) [fill=red,draw,anchor=west] at ([yshift=-20pt]c.south west){Person D};
\node[fill=purple,draw,anchor=west] at ([yshift=-20pt]d.south west){Person E};
\end{ganttchart}
\end{tikzpicture}
}
\end{figure}
\end{center}
\end{document}

Best Answer

OK. I used Alain Matthes's chart, updating it for the current version of the package.

Each time you add a node, the current bounding box changes to include that node. As the picture widens, each node ends up wandering further to the right. The easiest thing is to name the first node you add and then add the next node relative to that one rather than relative to the bounding box.

For example:

\documentclass[border=10pt,tikz,multi]{standalone}
\usepackage{pgfgantt}
\begin{document}
% updated from Alain Matthes's answer at https://tex.stackexchange.com/a/64863/
\begin{ganttchart}[y unit title=0.4cm,
  y unit chart=0.5cm,
  vgrid,hgrid,
  title label anchor/.style={below=-1.6ex},
  title left shift=.05,
  title right shift=-.05,
  title height=1,
  bar/.style={fill=gray!50},
  incomplete/.style={fill=white},
  progress label text={},
  bar height=0.7,
  group right shift=0,
  group top shift=.6,
  group height=.3,
  group peaks height={.2}
  ]{1}{24}
  %labels
  \gantttitle{Week}{24} \\
  \gantttitle{Monday}{4}
  \gantttitle{Tuesday}{4}
  \gantttitle{Wednesday}{4}
  \gantttitle{Thursday}{4}
  \gantttitle{Friday}{4}
  \gantttitle{Saturday}{4} \\
  %tasks
  \ganttbar{first task}{1}{2} \\
  \ganttbar{task 2}{3}{8} \\
  \ganttbar{task 3}{9}{10} \\
  \ganttbar{task 4}{11}{15} \\
  \ganttbar[progress=33]{task 5}{20}{22} \\
  \ganttbar{task 6}{18}{19} \\
  \ganttbar{task 7}{16}{18} \\
  \ganttbar[progress=0]{task 8}{21}{24}

  %relations
  \ganttlink{elem0}{elem1}
  \ganttlink{elem0}{elem3}
  \ganttlink{elem1}{elem2}
  \ganttlink{elem3}{elem4}
  \ganttlink{elem1}{elem5}
  \ganttlink{elem3}{elem5}
  \ganttlink{elem2}{elem6}
  \ganttlink{elem3}{elem6}
  \ganttlink{elem5}{elem7}
  \node (a) [fill=white,draw,anchor=west] at (current bounding box.north east){Box North East};
  \node (b) [fill=red,draw,anchor=west] at ([yshift=-20pt]a.south west){Box North East};
  \node (c) [fill=blue,draw,anchor=west] at ([yshift=-20pt]b.south west){Box North East};
  \node (d) [fill=yellow,draw,anchor=west] at ([yshift=-20pt]c.south west){Box North East};
  \node[fill=purple,draw,anchor=west] at ([yshift=-20pt]d.south west){Box North East};
\end{ganttchart}
\end{document}

legend boxes on right