目前我只能画出 3D 板,但我不知道如何使用 3D 正弦曲线来画。我画出了类似的东西,但我不知道如何在曲线中使用 2 种颜色和相同的形状。效果不太好!!
\documentclass {standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis]
\addplot3 [
domain=-2:2,
domain y = -2:2,
samples = 40,
samples y = 40,
surf,
fill=pink,
faceted color = teal] {-exp(-(x^2+y^2)/1.3};
\end{axis}
\end{tikzpicture}
\end{document}
你可以帮帮我吗?!
答案1
我不确定我是否理解了你的问题 - 看起来好像是你做的。- 无论如何,这里的表面有两种颜色和一些曲线。如果我误解了或者你在添加其余部分时遇到困难,请询问。
\documentclass[border=1cm]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfplotsset{colormap={violet}{rgb255=(25,25,122) rgb255=(238,140,238) color=(white)}}
\begin{document}
\begin{tikzpicture}[
declare function={
f(\x,\y)=-exp(-(\x^2+\y^2)/1.3;
}]
\begin{axis}[
view={30}{20},
mesh/interior colormap name=violet,
colormap/viridis,
hide axis,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=-2.5, zmax=0,
]
\addplot3[
domain=-2:2,
domain y=-2:2,
samples=40,
samples y=40,
surf,
] {f(\x,\y)};
\addplot3[
domain=-2:2,
samples=40,
samples y=1,
smooth,
] ( x , -2 , {f(\x,0)});
\addplot3[
domain=-2:2,
samples=40,
samples y=1,
smooth,
] ( x , -2 , {f(\x,1)});
\draw[->, thick] (0,-2,0) -- node[font=\tiny, pos=0.7, right=-2pt]{$W_{\text{max}}$} (0,-2, {f(0,0)});
\end{axis}
\end{tikzpicture}
\end{document}
按厚度编辑:
\documentclass[border=1cm]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfplotsset{colormap={violet}{rgb255=(25,25,122) rgb255=(238,140,238) color=(white)}}
\begin{document}
\begin{tikzpicture}[
declare function={
f(\x,\y)=-exp(-(\x^2+\y^2)/1.3;
}]
\begin{axis}[
view={30}{20},
mesh/interior colormap name=violet,
colormap/viridis,
hide axis,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=-2.5, zmax=0,
]
\addplot3[
domain=-2:2,
domain y=-2:2,
samples=40,
samples y=40,
surf,
] {f(\x,\y)};
\addplot3[
domain=-2:2,
domain y=0:360,
samples=40,
samples y=2,
surf,
] (x,-2,{f(\x,-2)-0.05*sin(\y r)});
\addplot3[
domain=-2:2,
domain y=0:360,
samples=40,
samples y=2,
surf,
] (2,x,{f(\x,2)-0.05*sin(\y r)});
\addplot3[
domain=-2:2,
samples=40,
samples y=1,
smooth,
] ( x , -2 , {f(\x,0)});
\addplot3[
domain=-2:2,
samples=40,
samples y=1,
smooth,
] ( x , -2 , {f(\x,1)});
\draw[->, thick] (0,-2,0) -- node[font=\tiny, pos=0.7, right=-2pt]{$W_{\text{max}}$} (0,-2, {f(0,0)});
\end{axis}
\end{tikzpicture}
\end{document}