5
  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 have

    What I want (automatically):

    what I (automatically) want

  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}
    }
    ]
    \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.

loosa2
  • 53

1 Answers1

3

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}}
}
]
\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}
StrongBad
  • 20,495