2

Why is it problamatic to switch the colormap and the interior colormap? The following works fine:

    mesh/interior colormap name=hot,
    colormap/blackwhite, 

but this does not:

    mesh/interior colormap name=blackwhite,
    colormap/hot, 

I want the second figure to have the interior in gray scale. I realize that this probably can be done by changing the domain and/or function, but would prefer to be able to just switch the colormaps as that would be much simpler.

enter image description here

References:

Code:

\documentclass[border=2pt]{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}%

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    xlabel=$x$,ylabel=$y$,
    %% ------------------------------------ This is fine
    mesh/interior colormap name=hot,
    colormap/blackwhite, 
 ]
  \addplot3 [domain=-1.5:1.5,surf, shader=faceted] {-exp(-x^2-y^2)};
\end{axis}
\end{tikzpicture}%
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    xlabel=$x$,ylabel=$y$,
    %% ------------------------------------ This does not work
%    mesh/interior colormap name=blackwhite,
    colormap/hot, 
 ]
  \addplot3 [domain=-1.5:1.5,surf, shader=faceted] {-exp(-x^2-y^2)};
\end{axis}
\end{tikzpicture}%
\end{document}
4

The design at this point is a little bit confusing. The situation is somehow like

\def\employBlackWhite{
    \def\colormap@BlackWhite{
        black --> white
    }
}
\show\colormap@BlackWhite

and the result is of course undefined.

so you have to say \pgfplotsset{colormap/blackwhite} in order to put the definition of blackwhite into the memory. Or, more compactly

\begin{axis}[
  hide axis,
  xlabel=$x$,ylabel=$y$,
  colormap/black, % employ blackwhite
  colormap/hot,   % employ hot & change the default to hot
  mesh/interior colormap name=blackwhite, % change the interior color
]

According to the manual

/pgfplots/colormap name={⟨color map name⟩}
Changes the current color map to the already defined map named ⟨color map name⟩.

/pgfplots/colormap={⟨name⟩}{⟨color specification⟩}
Defines a new colormap named ⟨name⟩ according to ⟨color specification⟩ and activates it using colormap name={⟨name⟩}.

So the same logic applies to the pair

/pgfplots/mesh/interior colormap name={⟨map name⟩}
/pgfplots/mesh/interior colormap={⟨map name⟩}{⟨colormap specification⟩}

They are pretty much like the relation between

\usebeamertemplate
\setbeamertemplate

|improve this answer|||||
  • +1 Of course. My reaction with the potential bug was too hasty. I'll delete it together with my answer. – Stefan Pinnow Mar 20 '17 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.