我有一个具有 2 个参数的函数,当以 3D 形式绘制时,它会以某种方式旋转,从而隐藏部分表面:
\begin{tikzpicture}[
declare function={
func(\x, \y) = ((\x<10) * (\x/10) + (\x>=10)) *
((\y<=30) * (\y/30) + (\y>30) * (1- (\y-30)/((\y-30)+3)));
}
]
\begin{axis}[
colormap name=whitered,
axis z line=middle,
xmin=0, xmax=50, xlabel=$d$,
ymin=0, ymax=30, ylabel=$v$,
zmin=0, zmax=1.1, zlabel=$\overline{f}$
]
\addplot3[domain=0:50, y domain=0:30, samples=50, surf] {func(\x, \y)};
\end{axis}
\end{tikzpicture}
为了防止这种情况,我想从“自上而下”的视图绘制它,然后仅依靠颜色来指示函数的值。如何做到这一点?
答案1
该选项/pgfplots/view={azimuth}{elevation}
将帮助您
\documentclass[border = 5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function={
func(\x, \y) = ((\x<10) * (\x/10) + (\x>=10)) *
((\y<=30) * (\y/30) + (\y>30) * (1- (\y-30)/((\y-30)+3)));
}
]
\begin{axis}[
view={-70}{50},
%axis z line=middle,
xmin=0, xmax=50, xlabel=$d$,
ymin=0, ymax=30, ylabel=$v$,
zmin=0, zmax=1.1, zlabel=$\overline{f}$,
]
\addplot3[domain=0:50, y domain=0:30, samples=50, surf] {func(\x, \y)};
\end{axis}
\end{tikzpicture}
\end{document}