如何将colormaps
库中的所有颜色图用作室内颜色图?以下是示例:
\documentclass[a4paper,12pt]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
height=10cm,
hide axis,
xlabel=$x$,ylabel=$y$,
]
\addplot3[domain=-1.5:1.5,opacity=0.7,surf,colormap/cold,
%mesh/interior colormap name=hot, %works
mesh/interior colormap name=gray, %doesn't work
]
{-exp(-x^2-y^2)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您必须colormaps
在使用之前明确地从库中“加载”颜色图(对于库的颜色图也是如此colorbrewer
。)所以您的问题实际上与 3D 图无关......
这里您的代码再次使用两个有效位置来“加载”色彩图。
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{
compat=1.13,
% either load the colormap here ...
% colormap/gray,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
height=10cm,
hide axis,
xlabel=$x$,
ylabel=$y$,
% ... or here
colormap/gray,
]
\addplot3[
domain=-1.5:1.5,
opacity=0.7,
surf,colormap/cold,
%mesh/interior colormap name=hot, %works
mesh/interior colormap name=gray, %doesn't work
] {-exp(-x^2-y^2)};
\end{axis}
\end{tikzpicture}
\end{document}