添加了 2 个区域的颜色。相反,我希望每个新区域都使用描述中定义的颜色覆盖先前的区域。
\begin{tikzpicture}[domain=0.001:160, samples=100]
\begin{axis}[
legend style={draw=none, legend columns=2, at={(.9,.9)}}]
\addplot [fill=blue, opacity=.3, draw=none, forget plot] {.508-1.52398*exp(-(13702.2/x)^0.13266)} \closedcycle;
\addplot [fill=violet, opacity=.3, draw=none, forget plot] {.445-0.34900*exp(-(30.0706/x)^0.23650)} \closedcycle;
\end{axis}
\end{tikzpicture}
答案1
一种方法是(如果我正确理解了您的问题)使用该stack plots
选项。首先,使用两个函数的差(其中差为正)绘制紫色区域,然后绘制蓝色区域。为了避免重复函数,declare function
可以使用该选项。
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[domain=0.001:160, samples=100]
\begin{axis}[
legend style={draw=none, legend columns=2, at={(.9,.9)}},
declare function={
f1(\x) = .508-1.52398*exp(-(13702.2/\x)^0.13266);
f2(\x) = .445-0.34900*exp(-(30.0706/\x)^0.23650);
pos(\x) = ifthenelse(\x>0,\x,0);
},
stack plots=y,
]
\addplot [fill=violet, opacity=.3, draw=none, forget plot] {f2(x)} \closedcycle;
\addplot [fill=blue, opacity=.3, draw=none, forget plot] {pos(f1(x)-f2(x))} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}
最终的剧情是: