使用 fillbetween 的奇怪 pgfplots 行为

使用 fillbetween 的奇怪 pgfplots 行为

我使用以下代码绘制一个简单的图形,并在其下方区域上色。预期结果是曲线下方区域完全填满。实际结果是颜色被对角线剪切:

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, enlarge x limits = 0.25, enlarge y limits = 0.25, axis x line = middle, axis y line = middle, x label/.append style = {at = {(current axis.right of origin)}, anchor = south west}, y label/.append style = {at = {(current axis.above origin)}, anchor = north west}, legend/.append style = {font = \small}, xtick = {0.3, 0.6}, xticklabels = {$\varphi_{1}$, $\varphi_{2}$}, ymajorticks = false, yminorticks = false, xlabel = $\varphi$, ylabel = $r$, name = polar]
\path [name path = axis] (axis cs:0,0) -- (axis cs:1,0);
\addplot [name path = r, smooth, mark = *] coordinates {
    (0.3, 0.6)
    (0.4, 0.65)
    (0.6, 0.5)
};
\addplot [fill = orange] fill between [of = r and axis, soft clip = {domain=0.3:0.6}];
\draw [dashed] (0.3, 0.6) -- (0.3, 0.6 |- {rel axis cs:0, 0});
\draw [dashed] (0.6, 0.5) -- (0.6, 0.5 |- {rel axis cs:0, 0});
\end{axis}
\end{tikzpicture}
\end{document}

请指教。

答案1

我没有真正的解决方案,只有一种解决方法。lualatex 似乎存在舍入误差问题。如果你稍微降低软剪辑的下限,它似乎有效。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat = newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, enlarge x limits = 0.25, enlarge y limits = 0.25, axis x line = middle, axis y line = middle, x label/.append style = {at = {(current axis.right of origin)}, anchor = south west}, y label/.append style = {at = {(current axis.above origin)}, anchor = north west}, legend/.append style = {font = \small}, xtick = {0.3, 0.6}, xticklabels = {$\varphi_{1}$, $\varphi_{2}$}, ymajorticks = false, yminorticks = false, xlabel = $\varphi$, ylabel = $r$, name = polar]
\path [name path = axis] (axis cs:0,0) -- (axis cs:1,0);
\addplot [name path = r, smooth, mark = *] coordinates {
    (0.3, 0.6)
    (0.4, 0.65)
    (0.6, 0.5)
};
\addplot [fill = orange] fill between [of = r and axis, soft clip =
{domain=0.299:0.6}];
\draw [dashed] (0.3, 0.6) -- (0.3, 0.6 |- {rel axis cs:0, 0});
\draw [dashed] (0.6, 0.5) -- (0.6, 0.5 |- {rel axis cs:0, 0});
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

我强调,这充其量只是一种解决办法。

相关内容