7

I my previous question, I rendered a 3d plot, but as I want to print my plots they should be in black, white or gray coloring format. How should I change the coloring scheme?

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}
    \directlua{
        q = function(x)
            return x-1
        end
            Z = function(x,y)
            return x^2+y^2+q(x)
        end
    }
    \pgfmathdeclarefunction{Z}{2}{%
        \edef\pgfmathresult{\directlua{tex.print(Z(\pgfmathfloatvalueof{#1},\pgfmathfloatvalueof{#2}))}}%
    }%
    \begin{axis}
    [
    grid=both,minor tick num=1,
    xlabel=$x$,ylabel=$y$,zlabel=$z$,
    enlargelimits,
    tick align=inside,
    domain=-1:1,
    samples=30,
    minor tick num=5,
    ]
    \addplot3 [surf] {Z(x,y)};
    \end{axis}
\end{tikzpicture}
\end{document}
enthu
  • 3,795

1 Answers1

12

Simply add the option

colormap/blackwhite

to the axis.

colored gray, black to white

Alternatively, define your own colormap for different gray versions. For example, also as axis option:

colormap = {whiteblack}{color(0cm)  = (white);color(1cm) = (black)}

colored gray, white to black

You define a distance between some colors, tell colors (like with xcolor and pgf/TikZ syntax in general), the color space will be linear interpolated. You can read more details about color maps in the pgfplots manual in 4.7.6 Color Maps.

Stefan Kottwitz
  • 231,401