我尝试在 LaTeX 文档中使用方程 e^(-x² - y²) 构建高斯密度,但结果并不能让我满意。
这是我的源代码。
提前致谢。 :)
\begin{tikzpicture}
\begin{axis}[view={25}{30},mark layer=like plot]
\addplot3 [draw=none, mark=*, mark size=2,
on layer=background,
z filter/.expression={z<exp(-x^2-y^2+15) ? z : nan}]
table[row sep=crcr] {%
0 0 15\\
0 0 -15\\
};
\addplot3 [
surf,
shader=faceted,
fill opacity=0.85,
samples=55,
domain=-4:4,
y domain=-4:4,
on layer=main,
] {exp(-x^2-y^2+14)};
\end{axis}
\end{tikzpicture}
这是我在网上找到的一张相当令人满意的图片:
答案1
似乎这个论坛还没有高斯密度表面。这里我使用渐近线。您可以包含pdf,png图像;或者直接在您的tex文档中使用asy代码,并加载包并asymptote
包含里面的代码。当然,您可以使用overleaf上的代码;\begin{asy}
\end{asy}
https://www.overleaf.com/read/fhdzfgcvdrvq
表面带有彩虹色调
// adapted from
// https://asymptote.sourceforge.io/gallery/3Dgraphs/elevation.asy
import graph3;
import palette;
currentprojection=orthographic(3,2,.4,zoom=.9);
unitsize(1cm,1cm,3cm);
defaultrender.merge=true;
real f(pair z) {return exp(-z.x*z.x-z.y*z.y);}
real a=2.5;
surface s=surface(f,(-a,-a),(a,a),25,Spline);
draw(s,mean(palette(s.map(zpart),Rainbow(40))),black);
xaxis3("$x$",-a-1,a+1,Arrow3);
yaxis3("$y$",-a-1,a+1,Arrow3);
zaxis3(Label("$z=e^{-(x^2+y^2)}$",align=E),0,1.3,Arrow3);
// Run on http://asymptote.ualberta.ca/
// modified from https://asymptote.sourceforge.io/gallery/3Dgraphs/AiryDisk.asy
unitsize(1cm,1cm,3cm);
import graph3;
currentprojection=orthographic(3,2,.4,zoom=.8);
real f(pair z) {real r=abs(z); return exp(-r^2);}
real a=3;
pen p=lightgreen;
surface s=surface(f,(-a,-a),(a,a),100,Spline);
draw(s,p);
xaxis3("$x$",Bounds,InTicks);
yaxis3("$y$",Bounds,InTicks);
zaxis3(Label(rotate(90)*"$z=e^{-(x^2+y^2)}$"),Bounds,InTicks("$%#.1f$"));
带网格的表面
// http://asymptote.ualberta.ca/
unitsize(1cm,1cm,3cm);
import graph3;
currentprojection=orthographic(3,2,.4,zoom=.9);
real f(pair z) {real r=abs(z); return exp(-r^2);}
real a=3;
pen p=yellow;
surface s=surface(f,(-a,-a),(a,a),20,Spline);
draw(s,p,meshpen=magenta);
xaxis3("$x$",-a-1,a+1,Arrow3);
yaxis3("$y$",-a-1,a+1,Arrow3);
zaxis3(Label("$z=e^{-(x^2+y^2)}$",align=E),0,1.3,Arrow3);