表面不显示 – pgfplots 3D

表面不显示 – pgfplots 3D

我正在尝试使用 pgfplots 包绘制这个表面 x^/25+y^2/9-z^2/100=-1

但什么也没有出现。

在此处输入图片描述

这是我的代码:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest, colormap={cm}{color(0)=(blue) color(1)=(blue!90) color(3)=(blue!80) color(4)=(blue!70) color(5)=(blue!10)}}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
axis lines = center,
axis line style = thick,
xlabel=$x$, ylabel=$y$, zlabel=$z$,
ylabel style={left},
ymin=-10,
ymax=10,
xmin=-20,
xmax=20,
zmin=-20,
zmax=20,
unit vector ratio=1 1 1,
xtick=\empty,
ytick=\empty,
ztick=\empty,
width=15cm
]
\addplot3[surf,mesh/ordering=y varies,shader=interp,opacity=0.7,
samples=71,samples y=41,domain y=-10:10,domain=-10:10]
({x^2/25},{x^2/9},{x^2/100-1});   
\end{axis}
\end{tikzpicture}

\end{document}

答案1

您发布的方程式可以求解 z,得出

z^2=100+4*x^2+100*y^2/9

所以必须策划

z=-sqrt(100+4*x^2+100*y^2/9)

z=+sqrt(100+4*x^2+100*y^2/9)

结果(我注释掉了,unit vector ratio=1 1 1因为看起来不太好)

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest, 
colormap={cm}{color(0)=(blue) color(1)=(blue!90) color(3)=(blue!80) color(4)=(blue!70) color(5)=(blue!10)}
}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
axis lines = center,
axis line style = thick,
xlabel=$x$, ylabel=$y$, zlabel=$z$,
ylabel style={left},
ymin=-10,
ymax=10,
xmin=-20,
xmax=20,
zmin=-20,
zmax=20,
%unit vector ratio=1 1 1,
xtick=\empty,
ytick=\empty,
ztick=\empty,
width=15cm
]
\addplot3[surf,mesh/ordering=y varies,
shader=interp,opacity=0.7,
samples=71,samples y=41,domain=-10:10,domain y=-10:10]
{-sqrt(100+4*x*x+100*y*y/9)};   

\addplot3[surf,mesh/ordering=y varies,
shader=interp,opacity=0.7,
samples=71,samples y=41,domain=-10:10,domain y=-10:10]
{sqrt(100+4*x*x+100*y*y/9)};   
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

可以切换到极坐标。

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest, 
colormap={cm}{color(0)=(blue) color(1)=(blue!90) color(3)=(blue!80) color(4)=(blue!70) color(5)=(blue!10)}
}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
axis lines = center,
axis line style = thick,
xlabel=$x$, ylabel=$y$, zlabel=$z$,
ylabel style={left},
ymin=-10,
ymax=10,
xmin=-20,
xmax=20,
zmin=-20,
zmax=20,
unit vector ratio=1 1 1,
xtick=\empty,
ytick=\empty,
ztick=\empty,
width=15cm
]
\addplot3[surf,z buffer=sort,
shader=interp,opacity=0.7,
samples=12,samples y=61,domain=0:2,domain y=0:360]
({x*cos(y)*5},{x*sin(y)*3},{-10*sqrt(1+x*x)});   

\addplot3[surf,z buffer=sort,
shader=interp,opacity=0.7,
samples=12,samples y=61,domain=0:2,domain y=0:360]
({x*cos(y)*5},{x*sin(y)*3},{10*sqrt(1+x*x)});   
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容