# Vertically aligned legend to PGFPlots subplots

What I want to do is to have 3 PGFPlots subplots and the legend arranged in four equally sized boxes. However, when I use the following code, in the output the legend is not vertically aligned with the bottom left plot. What should I do to make it vertically aligned at the center of the bottom row, which in my opinion would be more aesthetically pleasing?

\documentclass[12pt]{article}

\usepackage{pgfplots}

\begin{document}

\begin{tabular}{cc}
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth,
legend columns=1,
legend entries={blahblahblah\\},
legend to name=legend:aligning-subplots-legend]
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth]
\end{axis}
\end{tikzpicture}
\\
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth]
\end{axis}
\end{tikzpicture}
&
\ref{legend:aligning-subplots-legend}
\end{tabular}


-
Do all of the plots have the same x and y axis ranges? –  Jake Sep 7 '12 at 5:03
In this case they do, which hopefully makes that easier... –  I Like to Code Sep 7 '12 at 16:07

I did manage to find another post that was useful to me, see Vertically center cells of a table?

My solution and what the output looks like is below.

\documentclass[a4paper]{article}

\usepackage{array}% http://ctan.org/pkg/array
\usepackage{pgfplots}

\newcolumntype{M}{>{\centering\arraybackslash}m{\dimexpr.5\linewidth-2\tabcolsep}}

\begin{document}

\begin{figure}[h!]
\begin{center}
\begin{tabular}{MM}
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth,
legend columns=1,
legend entries={blahblahblah\\},
legend to name=legend:aligning-subplots-legend]
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth]
\end{axis}
\end{tikzpicture}
\\
\begin{tikzpicture}
\begin{axis}[width=0.45\textwidth]