[Tex/LaTex] PGF colorbar cuts off max value

pgfplotstikz-pgf

I need to generate a whole load of colorbars with custom min and max values.

From reading this SE I have managed to get this working:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    scale only axis,
    height=0pt,
    width=0pt,
    colormap/jet,
   colorbar,
   point meta min=0.0,
   point meta max=0.2860,
    colorbar style={ height= 10 cm},xtick={0,0.2860}]
    \addplot [draw=none] coordinates {(0,0)};
\end{axis}
\end{tikzpicture}

\end{document}

which produces this:

broken colorbar

It cuts off the top of the colorbar including the max value.

1) Why is this and how can I fix it?

2) How can I make the scale so it just has the min and max values?

Thanks

Best Answer

You have two problems: - standalone packages, which without defined border, for example border=5mm is (to) close to border of picture; - y range of your picture. If you set `point meta max=0.3, than the maximal value of your plot will appear.

\documentclass[border=5mm]{standalone}
    \usepackage{pgfplots}
\pgfplotsset{compat=newest}
    \begin{document}
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    scale only axis,
    height=0pt,
    width=0pt,    
    colormap/jet,
    colorbar,
    point meta min=0.0,
    point meta max=0.2860,
    colorbar style={height=4cm,
            /pgf/number format/precision=3,
            ytick={0,0.286}}]
    \addplot [draw=none] coordinates {(0,0)};
\end{axis}
\end{tikzpicture}
    \end{document}

For how to put only min and max value o your diagram, I don't know.

Edit: Considering comment of @Grimler, you can obtain:

enter image description here

Now the my MWE is complete ...