我正在使用和绘制一个3DBessel
函数。我想做的是在3d框的顶部绘制3d函数的投影。pgfplots
gnuplot
我想过使用contour gnuplot
绘图,但尽管使用了高number
轮廓,但我无法填充投影的整个表面,如下图所示
关于如何避免间隙并实现平滑填充的投影,您有什么想法吗?
该图像是使用以下代码制作的
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}
\begin{axis} [width=\textwidth,
height=\textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$\rho_x=k_xr_x$},
ylabel={$\rho_y=k_yr_y$},
zlabel={$j_l(\rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
\addplot3[surf,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
\addplot3[contour gnuplot={output point meta=rawz,
number=1000,
labels=false,},
z filter/.code={\def\pgfmathresult{2.5}},
domain=-3:3,
y domain=-3:3]
gnuplot {besj0(x**2+y**2)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
我不会绘制等高线图,而是用原始图的点元来绘制一个常数。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}
\begin{axis} [width=\textwidth,
height=\textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$\rho_x=k_xr_x$},
ylabel={$\rho_y=k_yr_y$},
zlabel={$j_l(\rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
\addplot3[surf, samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
\addplot3[surf, samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
point meta=rawz,
z filter/.code={\def\pgfmathresult{2.5}},
]
gnuplot {besj0(x**2+y**2)};
\end{axis}
\end{tikzpicture}
\end{document}
如果使用极坐标图,恕我直言,结果会变得更具吸引力。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}
\begin{axis} [width=\textwidth,
height=\textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$\rho_x=k_xr_x$},
ylabel={$\rho_y=k_yr_y$},
zlabel={$j_l(\rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
\addplot3[surf, samples=51,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};
\addplot3[surf, samples=51,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={\def\pgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};
\end{axis}
\end{tikzpicture}
\end{document}