[Tex/LaTex] Position of colorbar with multi plots without using groupplot

pgfplots

I have 6 plots (2 rows, 3 columns) with the same colormap and I want to put only one colorbar on the top of the plots. Using anchor and at does not give the expected result, I think this is because they refer to the axis and not to the colorbar (first image). Also if I put the anchor and at specifications inside colorbar style it does not work (second image). There is also a problem with the width of the colorbar, I set it to 3 times the axis width but it is a little shorter than expected.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}


\begin{document}
\pgfplotsset{every axis/.append style={font=\tiny}}
\pgfplotsset{mystyle/.style={
    scale only axis,
    height=.29\linewidth, width=.29\linewidth,
    colormap/cool,
    point meta min=-10,
    point meta max=10,
    view={0}{90}}}
\begin{tikzpicture}
\begin{axis}    [mystyle,
            name=frame66a,
            xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame66b,
            at={(frame66a.south west)},
            anchor=north west]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame100a,
            at={(frame66a.south east)},
            anchor=south west,
            yticklabels={,,}, xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame100b,
            at={(frame100a.south west)},
            anchor=north west,
            yticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame120a,
            at={(frame100a.south east)},
            anchor=south west,
            yticklabels={,,}, xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame120b,
            at={(frame120a.south west)},
            anchor=north west,
            yticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [hide axis,
                scale only axis,
            height=0pt, width=0pt,
            colormap/cool,
            colorbar horizontal,
            colorbar style={width=.87\linewidth},
            point meta min=0,
            point meta max=350,
            at={(frame120a.north east)},
            anchor=south east]
    \addplot [draw=none] coordinates {(0,0)};
\end{axis}
\end{tikzpicture}
\end{document} 

enter image description here

enter image description here

Best Answer

I came to a solution. I made an axis environment large as 3 axis and high as 2 axis and I put its colorbar on top using at and anchor:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}


\begin{document}
\pgfplotsset{every axis/.append style={font=\tiny}}
\pgfplotsset{mystyle/.style={
    scale only axis,
    height=.3\linewidth, width=.3\linewidth,
    colormap/cool,
    point meta min=-10,
    point meta max=10,
    view={0}{90}}}
\begin{tikzpicture}
\begin{axis}    [mystyle,
            name=frame66a,
            xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame66b,
            at={(frame66a.south west)},
            anchor=north west]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame100a,
            at={(frame66a.south east)},
            anchor=south west,
            yticklabels={,,}, xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame100b,
            at={(frame100a.south west)},
            anchor=north west,
            yticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame120a,
            at={(frame100a.south east)},
            anchor=south west,
            yticklabels={,,}, xticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [mystyle,
            name=frame120b,
            at={(frame120a.south west)},
            anchor=north west,
            yticklabels={,,}]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\begin{axis}    [hide axis,
                scale only axis,
            height=.6\linewidth, width=.9\linewidth,
      at={(frame66a.north west)}, anchor=north west,
            colormap/cool,
            colorbar horizontal,
       colorbar style={height=.03\linewidth, at={(0,1.05)},anchor=south west},
            point meta min=0,
            point meta max=350]
    \addplot [draw=none] coordinates {(0,0)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here