[Tex/LaTex] Pgfplots: Horizontal colorbar on top

pgfplots

I found on pgfplots manual ho to have an horizontal colorbar (simply specifying the colorbar horizontal option) but how can I put it above the axis? By default pgfplots puts it below the axis..

Here a MWE:

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

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    view={0}{90}
    colormap/cool,
    colorbar horizontal]
    \addplot3[surf,shader=flat] {x+y};
\end{axis}
\end{tikzpicture}
\end{document} 

Best Answer

Any colorbar style change will be redefined by colorbar horizontal and the alikes. Thus the new style must be placed AFTER colorbar horizonal.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={0}{90},
colormap/cool, 
colorbar horizontal,
colorbar style={
at={(0,1.2)},anchor=north west}
]
\addplot3 [surf, shader=flat] {x+y};
\end{axis}
\end{tikzpicture}
\end{document} 

For more information, please refer to its manual p 140-142.

enter image description here