This here is a question which came on the pgfplots mailing list; I answer it here since this allows an answer of higher quality.
I have a picture that uses a diverging color map.
In this case, minimum and maximum don’t have the same absolute value (but -0.2 and +0.5 instead)
I want to be able to do a "centered color map", where “0” is the middle color, all points >0 use the upper half of the map, and all <0 the lower half.
The color bar should be skewed according to the real values (i.e. the lower half of the map should take up 2/7 of the bar,a nd the upper half the remaining 5/7)
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
% I want the color to be distributed in a nonlinear way, not like this
% I want the tick labels to reflect the centered colorbar
colorbar,
]
\addplot[line width=3pt,mesh,domain=-0.2:0.5] {x};
\end{axis}
\end{tikzpicture}
\end{document}
maybe a point meta center=[auto,] key, with auto meaning a calculated value of (point meta max + point meta min) ÷ 2