Plotting the Scherk surface with TikZ

3dpgfplotstikz-pgf

How would one go about plotting the Scherk surface with TikZ?
The Sherk surface is defined as the graph of

log(cos(x)/cos(y)), where -pi/2 < x,y < pi/2

I tried this:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{width=10cm, compat=1.16}

\pgfplotscreatecolormap{bw}{color=(lightgray) color=(white) color=(lightgray)}

\begin{document}
    
    \begin{tikzpicture}
        \begin{axis}
            [
            view={60}{30},
            hide axis,
            colormap name =bw,
            ]
            \addplot3[surf,shader = faceted interp,
            domain=-pi/2+0.0001:pi/2-0.0001,
            domain y = -pi/2+0.0001:pi/2-0.0001,
            samples=20,
            colormap name =bw,
            samples y=20,
            ]
            ({x},
            {y},
            {log10(cos(deg(x))/cos(deg(y)))});
        \end{axis}
    \end{tikzpicture}
    
\end{document}

but only got 'ugly' results…
Is there a way to plot the Sherk surface in this way (with this colormap etc.)?
I already plotted the helicoid in a similar way and want the pictures to "look the same" (same colormap and stuff)…

The desired aesthetic would be:

helicoid

What I got is:

scherk

But I'd rather get something like

scherk

Best Answer

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfplotsset{colormap={CM}{color=(lightgray) color=(white) color=(lightgray)}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={60}{30},
hide axis,
zmin=-0.4, zmax=0.4,
trig format plots=rad,
clip=false,
]
\addplot3[
surf, shader=faceted interp,
domain=-pi/2+0.1:pi/2-0.1,
samples=20,
] ( x, y , {log10(cos(x)/cos(y))} );
\end{axis}
\end{tikzpicture}
\end{document}

Scherk surface gray shaded

Edit: The same plot with these limits: domain=-pi/2+0.0001:pi/2-0.0001,

Scherk surface gray shaded with higher wings

The important thing is not the limits, but the z-scale. As you do not show any z-axis, the choice zmin=-0.4, zmax=0.4 is only based on how "round" you would like the plot to appear - your original plot is not wrong.