使用漂亮的 pgfplots 系统,我想创建一个包含同一对轴的三个轮廓图的图表,每个图使用不同的颜色图。以下代码有效:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.14}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
contour/label distance={150pt}
}
\def\f(#1,#2){(((1-x)*(#1)*max(0, (#2) - (1 - (#2)) * y / ((1 - x) * (#1))) + y)^(#2))*((1 - max(0, (#2) - (1 - (#2)) * y / ((1 - x) * (#1))))^(1 - (#2)))}
% w = 1, beta = 0.4
\pgfplotsset{
colormap={red}{rgb255(0cm)=(255,0,0); rgb255(1cm)=(255,255,255);}
}
\begin{axis}[
domain=0:1,
y domain=0:1,
view={0}{90}
]
\addplot3[contour gnuplot]
{\f(1,0.4)};
\end{axis}
% w = 1, beta = 0.5
\pgfplotsset{
colormap={green}{rgb255(0cm)=(0,255,0); rgb255(1cm)=(255,255,255);}
}
\begin{axis}[
domain=0:1,
y domain=0:1,
view={0}{90}
]
\addplot3[contour gnuplot]
{\f(1,0.5)};
\end{axis}
% w = 1, beta = 0.6
\pgfplotsset{
colormap={blue}{rgb255(0cm)=(0,0,255); rgb255(1cm)=(255,255,255);}
}
\begin{axis}[
domain=0:1,
y domain=0:1,
view={0}{90}
]
\addplot3[contour gnuplot]
{\f(1,0.6)};
\end{axis}
\end{tikzpicture}
\end{document}
输出为
但如果我更改某些参数,y 轴就会变得混乱。例如,如果我更改\addplot3[contour gnuplot]
为\addplot3[contour gnuplot={levels={0.1,0.3,0.5,0.7,0.9}}]
(对于所有\addplot3
s),则垂直轴不会对齐(并且y domain=0:1
不尊重该选项):
有任何想法吗?