I'm using addplot3 to create a surface, but I want a particular curve of points on the surface to be highlighted. Not something as simple as a level set curve. As a result, some of the curve should be hidden behind the surface, but I see no way to do this without actually breaking down the curve into the parts that should be behind the surface and the parts that should be in front of the surface.
This is the best I can do so far, but isn't right, as the spiral is permanently in front.
\documentclass[border=15pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps,fillbetween}
\begin{document}
\pgfplotsset{compat=1.10,
colormap/red/.style={
colormap={red}{
rgb=(1.0, 0.0, 0.0)
rgb=(1.0, 0.0, 0.0)
}
}
}
\begin{tikzpicture}
\pgfdeclarelayer{pre main}
\pgfsetlayers{pre main,main}
\begin{axis}[
hide axis,
colormap/bone,
view={25}{20}
]
\addplot3 [surf,
colormap/bone, %colour scheme
domain=0*pi:4*pi, %sets range for x
y domain=0:4*pi, %sets range for y
samples=50, %number of samples taken
z buffer=sort]
(
{cos(\x r)},
{sin(\x r)},
{\y}
);
\addplot3 [surf,
colormap/red, %colour scheme
domain=0*pi:4*pi, %sets range for x
y domain=0:4*pi, %sets range for y
samples=50, %number of samples taken
z buffer=sort]
(
{cos(\x r)},
{sin(\x r)},
{\x}
);
\end{axis}
\end{tikzpicture}
\end{document}


asymptotehas a 3d engine and spares you from that, but AFAIK there is no fully automatic solution in pgfplots. You can use tricks likerestrict expr to domainfor the curve, though. – Apr 16 '20 at 20:06