3D pgfplots 示例的奇怪行为

3D pgfplots 示例的奇怪行为

我正在尝试重复使用这一页另一个极坐标图。即 r=a*sin(n.theta)。输出结果与我预期的差不多,我将在此处发布

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots} 
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar} 
\usepackage{subcaption}
\usepackage{floatrow} 
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines = none,
xmin=-1, xmax=1,
ymin=-1, ymax=1,
zmin=0, zmax=1,
] %<- done it in a similar way to 2D plots not quite sure it worsk liek that in 3D
\addplot3[domain=54:126,domain y=0:180,samples=31,
colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({(sin(5*x)*cos(x))*cos(y)}, 
{(sin(5*x)*cos(x))*sin(y)}, 
{(sin(5*x))*sin(x)});
\end{axis}
\end{tikzpicture}
\end{document}

但附图中红色圈出的负片部分我无法去除。提前致谢,在此处输入图片描述

答案1

如果您的问题是如何去除带有负片的部分z:这是一种方法。

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots} 
\pgfplotsset{width=8cm,compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines = none,
xmin=-1, xmax=1,
ymin=-1, ymax=1,
zmin=0, zmax=1,
] %<- done it in a similar way to 2D plots not quite sure it worsk liek that in 3D
\addplot3[domain=54:126,domain y=0:180,samples=31,
colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({ifthenelse((sin(5*x))*sin(x)>0,(sin(5*x)*cos(x))*cos(y),0)}, 
{ifthenelse((sin(5*x))*sin(x)>0,(sin(5*x)*cos(x))*sin(y),0)}, 
{max((sin(5*x))*sin(x),0)});
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

其他方法包括使用过滤器,或者仅使用其他域。

相关内容