我正在使用以下代码在 3D 中绘制一个圆锥体:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
domain=0:1,
y domain=0:2*pi,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=-1.5, zmax=0.1,
colormap/blackwhite,
samples=20,
samples y=20,
z buffer=sort,
unit vector ratio=1 1 1
]
\addplot3[surf] ({x*cos(deg(y))},{x*sin(deg(y))},{-x});
\end{axis}
\end{tikzpicture}
\end{document}
但是,我在顶部附近发现了几条奇怪的延伸线。我该如何去掉它们?
谢谢!
答案1
添加miter limit=1
后尖峰就会消失。
% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5,
zmin=-1.5, zmax=0.1,
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
domain=0:1,
y domain=0:2*pi,
samples=20,
samples y=20,
z buffer=sort,
unit vector ratio=1 1 1,
colormap/blackwhite,
miter limit=1, % <-- added
]
\addplot3[surf] ({x*cos(deg(y))},{x*sin(deg(y))},{-x});
\end{axis}
\end{tikzpicture}
\end{document}