# Scaling colormaps with pgfplots

I have two surface plots, which I would like to have to same color for the same height. So, as the first plot is dark blue for f(x,y)=0, the right plot should also be dark blue for f(x,y)=0. However, the color dark blue is assigned to the lowest point of the plot. Thus, the color for f(x,y) in the right plot is a bright orange.

Sample source:

\documentclass{report}
\usepackage{pgfplots}

\begin{document}

% first plot
\begin{tikzpicture}
\begin{axis}[]
\end{axis}
\end{tikzpicture}

% second plot
\begin{tikzpicture}
\begin{axis}[]
\end{axis}
\end{tikzpicture}

\end{document}


How can I force the plots to have the same color for the same height?

• Do the plot shapes look like you want them to? Are you trying to plot z=e^(-(x^2)-(y^2)) or z=e^((-x)^2+(-y)^2)? – Jake Dec 22 '11 at 22:15
• Actually the pictures above are not the plots of my example, the correct pictures can be found in the answer below. I dont know why Werner has modified my plotting functions. Anyway, I actually want to plot something totally different, the Gaussian function is just here to show what I am talking about. Also note that z=e^((-x)^2+(-y)^2) = z=e^(x^2+y^2), so I do not understand your question. – Peter Dec 23 '11 at 8:49
• Yeah, (-x)^2 = x^2, but that's not what I wrote. I said -(x^2). – Jake Dec 23 '11 at 12:50
• @Werner: Which version of PGF and PGFplots do you use? I get a different output from compiling Peter's code than the image you embedded, using tikz.sty 2010/10/13 v2.10 and pgfplots.sty 2011/07/29 v1.5 – Jake Dec 23 '11 at 12:55
• @Jake: Perhaps you can update the image with the appropriate output, since I added it from a system still running TeX Live 2009. I had thought an image would clearly show the problem, but if the output differs greatly, change or remove it. – Werner Dec 23 '11 at 15:50

By default, PGFplots will stretch the colormap to span the whole range of meta values (which, by default, are the y values) of all the plots in the axis. In your case, you would need to set the range explicitly. You can do this using point meta min=... and point meta max=....

\documentclass{report}
\usepackage{pgfplots}

\begin{document}

% first plot
\begin{tikzpicture}
\begin{axis}[point meta min=-1, point meta max=1]