![pgfplots-带有覆盖线的三维图](https://linux22.com/image/445232/pgfplots-%E5%B8%A6%E6%9C%89%E8%A6%86%E7%9B%96%E7%BA%BF%E7%9A%84%E4%B8%89%E7%BB%B4%E5%9B%BE.png)
你好呀
绘制的某些 3D 图形中pgfplots
有应该隐藏的线和平面,但却显示在前面的线和平面前面,如何解决这个问题?
梅威瑟:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat = newest,
width = 10cm, % width
height = 7cm, % height
samples = 10,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis]
% Hiperbole
\addplot3 [
% Aparence
surf,
opacity = 0.5,
fill opacity = 1,
faceted color = white,
shader = faceted interp,
% Scope
data cs = cart, % cart/polar/polarrad
% Variable
variable = \u,
variable y = \v,
domain = -1:1,
domain y = 0:360,
](
{cosh(u)*cos(v)},
{cosh(u)*sin(v)},
{sinh(u)}
);
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[hide axis]
% Elipse
\addplot3 [
% Aparence
surf,
opacity=0.5,
fill opacity= 1,
faceted color = white,
shader=faceted interp,
% Scope
data cs = cart, % cart/polar/polarrad
% Variable
variable = \u,
variable y = \v,
domain = 0:360,
domain y = -180:0,
]
(
{cos(u)*sin(v)},
{sin(u)*sin(v)},
{cos(v)}
);
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以对 z 缓冲区进行排序 -z buffer=sort
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat = newest,
width = 10cm, % width
height = 7cm, % height
samples = 10,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis]
% Hiperbole
\addplot3 [
% Aparence
surf,
opacity = 0.5,
fill opacity = 1,
faceted color = white,
shader = faceted interp,
% Scope
data cs = cart, % cart/polar/polarrad
% Variable
variable = \u,
variable y = \v,
domain = -1:1,
domain y = 0:360,
z buffer=sort,
](
{cosh(u)*cos(v)},
{cosh(u)*sin(v)},
{sinh(u)}
);
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[hide axis]
% Elipse
\addplot3 [
% Aparence
surf,
opacity=0.5,
fill opacity= 1,
faceted color = white,
shader=faceted interp,
% Scope
data cs = cart, % cart/polar/polarrad
% Variable
variable = \u,
variable y = \v,
domain = 0:360,
domain y = -180:0,
z buffer=sort,
]
(
{cos(u)*sin(v)},
{sin(u)*sin(v)},
{cos(v)}
);
\end{axis}
\end{tikzpicture}
\end{document}