以下 MWE 完全符合我的要求。我只是想知道是否有更简单、“规范”的方式来指定颜色图,因为我只想要黑线。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={300}{30}, hide axis=true, ticks=none, unit vector ratio=1.5 1.5 1, line join=round]
\addplot3[surf, samples=61, domain=-5:5, line width=0.2pt, fill=white, colormap={bw}{gray(0cm)=(0);gray(1cm)=(0);}] {sin(deg(x*y/5))*cos(deg(x*y/2))};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以更简单地定义颜色图,例如通过colormap={bw}{color=(black) color=(black)}
。但您也可以按以下方式进行。请参阅代码注释中的详细信息。
% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.16,
% load a colormap that already included black
% (either at the beginning or at the end)
colormap/blackwhite,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={300}{30},
hide axis=true,
ticks=none,
unit vector ratio=1.5 1.5 1,
line join=round,
samples=61,
]
\addplot3 [
surf,
line width=0.2pt,
fill=white,
% set the `point meta` value to a constant value
point meta=0,
] {sin(deg(x*y/5))*cos(deg(x*y/2))};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
你似乎正在寻找一个mesh
情节,而不是surf
。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={300}{30}, hide axis=true, ticks=none, unit vector ratio=1.5 1.5 1, line join=round]
\addplot3[mesh, samples=61, domain=-5:5, line width=0.2pt,draw=gray] {sin(deg(x*y/5))*cos(deg(x*y/2))};
\end{axis}
\end{tikzpicture}
\end{document}