\begin{tikzpicture}[scale=1]
\begin{groupplot}[group style={group name=plot2, group size= 2 by 2},width=\textwidth]

\nextgroupplot[ 
 width=0.45\columnwidth, 
 height=0.3\columnwidth, 
 xmin=0, 
xmax= 5000,
 xmajorgrids, 
ymode=log,
 yminorticks=true, 
 ymajorgrids, 
 yminorgrids, 
 ylabel={Suboptimality },
 xlabel={Wallclock time (s)},
 %x label style={at={(axis description cs:0.5,-0.05)},anchor=north},
 ]




 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=blue, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none
 ] 
file {  num_res/criteo/dave_rpg.csv };
 \label{plots1:dave}


 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=gray, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none,
 ] 
file {  num_res/criteo/synch_gd.csv };
 \label{plots1:gd}

 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=green!40!black, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none
 ] 
file {  num_res/criteo/piag.csv };
 \label{plots1:piag}



\nextgroupplot[ 
 width=0.45\columnwidth, 
 height=0.3\columnwidth, 
xmin = 0,
xmax= 5000,
 xmajorgrids, 
 ymode=log,
 yminorticks=true, 
 ymajorgrids, 
 yminorgrids, 
 %ylabel={Functional error },
 xlabel={Wallclock time (s)},
 %x label style={at={(axis description cs:0.5,0.05)},anchor=north},
 ]





 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=blue, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none
 ] 
file {  num_res/url/dave_rpg.csv };



 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=gray, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none
 ] 
file {  num_res/url/synch_gd.csv };

 \addplot [  each nth point=3, filter discard warning=false, unbounded coords=discard, 
 color=green!50!black, 
 solid, 
 line width=2.0pt, 
 mark size=2.5pt, 
 mark=none
 ] 
file { num_res/url/piag.csv };



\end{groupplot}

\node[anchor=north] at ($(plot2 c1r1.south)+(0,-1.0)$) { \small (a) Criteo };
%\node[anchor=north] at ($(plot2 c1r1.south)+(0,-1.4)$) { \footnotesize $m=45,840,617$, $\lambda_1=10^{-11}$, $\lambda_2=0$};

\node[anchor=north] at ($(plot2 c2r1.south)+(0,-1.0)$) { \small (b) URL };
%\node[anchor=north] at ($(plot2 c2r1.south)+(0,-1.4)$) { \footnotesize $m=2,396,130$, $\lambda_1=10^{-7}$, $\lambda_2=0$ };


% legend
\path (plot2 c1r1.north west|-current bounding box.north)--
      coordinate(legendpos)
      (plot2 c2r1.north east|-current bounding box.north);
\matrix[
    matrix of nodes,
    anchor=south,
    draw,
    inner sep=0.2em,
    draw
  ]at([yshift=1ex]legendpos)
  {
    \ref{plots1:dave}& \texttt{DAve-RPG} $p=1$ &[5pt]
\ref{plots1:gd}& Synchronous PG &[5pt]
\ref{plots1:piag}&   PIAG \\
};
\end{tikzpicture}
