答案1
这完美地说明了无需动画的概念。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{colorbrewer}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,ymin=0,xmin=0,zmin=0,zmax=50,smooth,
colormap/PuBu,point meta=-z-x-y,view={115}{30},
xtick=\empty,ytick=\empty,ztick={0,45},
declare function={f(\x)=30+15*cos(\x*36);}]
\pgfplotsinvokeforeach{20,25,30,35,40,45}{%
\draw[red] (7,7,0) circle[radius={acos((#1-30)/15)/36}];
\draw[dashed] (7,{7-acos((#1-30)/15)/36},0) --
(7,{7-acos((#1-30)/15)/36},#1) (7,{7+acos((#1-30)/15)/36},0) --
(7,{7+acos((#1-30)/15)/36},#1);
}
%
\addplot3[domain=-5:5,color=gray,samples y=0] ({7},{7+x},{f(x)});
%
\addplot3[surf,shader=interp,domain y=0:360,domain=0:5,z buffer=sort,opacity=0.5]
({7+x*cos(y)},{7+x*sin(y)},{f(x)});
\end{axis}
\end{tikzpicture}
\end{document}
或者带有动画。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16,width=14cm}
\usepgfplotslibrary{colorbrewer}
\begin{document}
\foreach \imin in {40,35,...,15}
{\begin{tikzpicture}[declare function={f(\x)=30+20*cos(\x*36);
finv(\x)=acos((\x-30)/20)/36;}]
\pgfmathsetmacro{\xmax}{finv(\imin+5)}
\begin{axis}[axis lines=middle,
xmin=0,xmax=12.5,ymin=0,ymax=12.5,zmin=0,zmax=50,smooth,
colormap/PuBu,point meta=-z-x-y,point meta max=-20,point meta min=-70,
view={115}{20},
xtick=\empty,ytick=\empty,ztick={0,45}]
\draw[dashed] (7,{7-finv(45)},45) -- (0,0,45);
\pgfplotsinvokeforeach{45,40,...,20}{%
\ifnum##1>\imin
\draw[red] (7,7,0) circle[radius={finv(##1)}];
\draw[dashed] (7,{7-finv(##1)},0) --
(7,{7-finv(##1)},##1) (7,{7+finv(##1)},0) --
(7,{7+finv(##1)},##1);
\fi
}
%
\addplot3[domain=-5:5,color=gray,samples y=0] ({7},{7+x},{f(x)});
%
\addplot3[surf,shader=interp,domain y=0:360,domain=0:\xmax,z buffer=sort,
opacity=0.8]
({7+x*cos(y)},{7+x*sin(y)},{f(x)});
\end{axis}
\end{tikzpicture}}
\end{document}