PGFPlots: Automatically forcing ticks at the end of an axis

1. I would like the ticks of the colormap from the first picture below to show the maximum and minimum of the data like in the second picture, in this case 1.35 and -0.26. I know I can do it through uncommenting the line which has extra y ticks=..., but I want to do it automatically.

What I have:

What I want (automatically):

2. I would like to only show one integer after the decimal point only for the minimum and maximum (in this case 1.3 and -0.2). But this isn't crucial, since I can round my data in Matlab, but I'd like to avoid that.

\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
small,
view={0}{90},
colorbar,
colorbar style={
%extra y ticks={-0.26,1.35}
}
]
coordinates {
(0,0,-0.26) (1,0,0)

(0,1,0) (1,1,1.35)
};
\end{axis}
\end{tikzpicture}
\end{document}


edit:

In the real application i am importing data from matlab, so simply defining a variable, which could be a half-automatic solution in this example, isnt possible.

You can get the minimum and maximum values with \pgfkeysvalueof{/pgfplots/ymin} and \pgfkeysvalueof{/pgfplots/ymax}}

I only have TL 2015 so I need 1.12, but I don't see why this wouldn't work in 1.13

\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
small,
view={0}{90},
colorbar,
colorbar style={
extra y ticks={\pgfkeysvalueof{/pgfplots/ymin},\pgfkeysvalueof{/pgfplots/ymax}}
}
]

• @loosa2 I missed part 2. You could do something like y tick label style = {/pgf/number format/.cd, fixed, precision=1} to get -.03 and 1.4 (i.e., it rounds instead of flooring and ceiling). There are a fair number of questions on the number formatting in PGF (e.g., tex.stackexchange.com/questions/96347/…). If you do not find something, it seems like a reasonable follow on question. Commented Jul 5, 2016 at 18:57