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):
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} } ] \addplot3[surf,shader=interp,patch type=bilinear] 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.


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., http://tex.stackexchange.com/questions/96347/pgfplots-number-format-on-axis). If you do not find something, it seems like a reasonable follow on question. – StrongBad Jul 05 '16 at 18:57