Here is the code. In the actual document this code is within a subfigure, and there is a preamble with a lot of \usepackage statements. The pgfonlayer statements are commented out in the code below, towards the end and surrounding some \draw statements. I am using TexMaker 4.5.
\begin{tikzpicture}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
%--------Left axis--------
\begin{axis}[width=6.0cm,height=5.0cm,scale only axis,
unbounded coords=jump,
stack plots=y,area style,
xticklabel style={font=\scriptsize},
xlabel style={font=\scriptsize},
yticklabel style={font=\scriptsize},
ylabel style={font=\scriptsize},
xmin=10.0,xmax=60.0,
ymin=20.0,ymax=40.0,
xlabel={target time},
ylabel={agents},
legend entries={ready,
talk},
legend style={font=\scriptsize,rounded corners=2pt,
at={(rel axis cs:0.02,0.50)},anchor=west}]
\addlegendimage{area legend,black,no markers,fill=green}
\addlegendimage{area legend,black,no markers,fill=blue}
\addplot [mark=none,fill=green]
coordinates {
(10,30)(12.7,30)(12.7,30)(28.45,30)(28.45,30)(53.83,30)(53.83,30)
(60,30)}\closedcycle;
\addplot [mark=none,fill=blue]
coordinates {
(10,6)(12.7,6)(12.7,5)(28.45,5)(28.45,4)(53.83,4)(53.83,3)
(60,3)}\closedcycle;
%\begin{pgfonlayer}{foreground}
\draw[dotted](axis cs:12.70,20.00)--(axis cs:12.70,40.00);
\draw[dotted](axis cs:28.45,20.00)--(axis cs:28.45,40.00);
\draw[dotted](axis cs:53.83,20.00)--(axis cs:53.83,40.00);
%\end{pgfonlayer}
\draw[dotted](axis cs:60.00,20.00)--(axis cs:60.00,40.00);
\end{axis}
\end{tikzpicture}