我想填充两条大致垂直的曲线之间的区域。它们略微向侧面倾斜,而且很平滑,但当我smooth
从\addplot
选项中移除时,问题仍然存在。之间的区域没有像我预期的那样被阴影化。相反,我看到:
如果我改变坐标,使线条不向两侧变细,我就会得到我期望的结果:
有没有办法填充曲线之间的整个区域?
这是我尝试过的:
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=1,
ymin=0, ymax=1,
]
\addplot [name path=left,gray,thick,mark=none,smooth] coordinates {
(0.45, 0.25) (0.40, 0.8) (0.35, 1.0) };
\addplot [name path=right,gray,thick,mark=none,smooth] coordinates {
(0.55, 0.26) (0.60, 0.8) (0.65, 1.0) };
\addplot [gray!90] fill between[of=left and right];
\end{axis}
\end{tikzpicture}
答案1
当然,只需添加reverse=true
到fill between
选项中即可。
% used PGFPlots v1.18.1
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=1,
ymin=0, ymax=1,
]
\addplot [name path=left,blue,thick,mark=none,smooth] coordinates {
(0.45, 0.25) (0.40, 0.8) (0.35, 1.0) };
\addplot [name path=right,red,thick,mark=none,smooth] coordinates {
(0.55, 0.26) (0.60, 0.8) (0.65, 1.0) };
\addplot [gray!90] fill between[
of=left and right,
reverse=true,
];
\end{axis}
\end{tikzpicture}
\end{document}