TikZ:如何防止 tikzfillbetween 与边界路径重叠?

TikZ:如何防止 tikzfillbetween 与边界路径重叠?

对于此代码,曲线之间的填充与箭头线宽的一半重叠,如垂直箭头所示。那么,如何确保它不与任何边界路径重叠?

此外,对于\tikzfillbetween,我想知道如何让它接受两个以上的周围路径。例如,如何判断\tikzfillbetween要填充的区域是由路径Paxis和形成Raxiscurve

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots,tikz}
\usetikzlibrary{shapes.geometric,hobby,arrows.meta}
\usepgfplotslibrary{fillbetween}


\begin{document}
    \begin{tikzpicture}[x=1.5mm,y=1.5mm]
        \draw[ultra thick, ->, name path=Paxis] (0,0) ++(0,15) -- ++(0,-10) coordinate (tipParrow);
        \draw[ultra thick, ->, name path=Raxis] (0,0) ++(0,15) -- ++(10,0) coordinate (tipRarrow);
        \draw [ultra thick,name path=curve] [use Hobby shortcut] (tipParrow) ++(0,2) .. ++(2,1) .. ++(2,4.5) .. ([shift={(-2,0)}]tipRarrow);
        \tikzfillbetween[ of=curve and Raxis, split] {red};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

将填充放在背景层上:

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta, backgrounds, hobby, shapes.geometric,}
\usepgfplotslibrary{fillbetween}

\begin{document}
    \begin{tikzpicture}[x=1.5mm,y=1.5mm]
        \draw[ultra thick, ->, name path=Paxis] (0,0) ++(0,15) -- ++(0,-10) coordinate (tipParrow);
        \draw[ultra thick, ->, name path=Raxis] (0,0) ++(0,15) -- ++(10,0) coordinate (tipRarrow);
        \draw [ultra thick,name path=curve] [use Hobby shortcut] (tipParrow) ++(0,2) .. ++(2,1) .. ++(2,4.5) .. ([shift={(-2,0)}]tipRarrow);
    \scoped[on background layer]
        \tikzfillbetween[ of=curve and Raxis, split] {red};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

编辑: 我将上面的代码简化为:

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta, backgrounds, hobby, shapes.geometric,}
\usepgfplotslibrary{fillbetween}


\begin{document}
    \begin{tikzpicture}[x=1.5mm,y=1.5mm]
        \draw[ultra thick, Straight Barb-Straight Barb, name path=Paxis] 
            (0,-10) coordinate (tipParrow) |- (10,0) coordinate (tipRarrow);
        \draw [ultra thick,name path=curve] [use Hobby shortcut] 
            (tipParrow) ++(0,2) .. ++(2,1) .. ++(2,4.5) .. ([shift={(-2,0)}]tipRarrow);
        \scoped[on background layer]
        \tikzfillbetween[of=curve and Paxis, split] {red};
    \end{tikzpicture}
\end{document}

现在的结果是:

在此处输入图片描述

你的第二个问题:上面的代码部分解决了它。

相关内容