0

I am trying to fill the space between two inward offsets of a polygone. Thanks to this fantastic answer I could figure out how to create the inward shapes. However, I cannot find a way to fill the area between both paths using the even odd rule.

Here's a MWE:

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{nfold}

\makeatletter \tikzset{offset/.code=\tikz@addmode{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}} \makeatother

\begin{document} \begin{tikzpicture} \begin{axis}[ ymode=log, xmin=0, xmax=200, ymin=1, ymax=10000, grid=both]

\begin{scope}[even odd rule]
    \fill
[postaction={offset=-1pt, draw=red}]
[postaction={offset=-3pt, draw=blue}]

(axis cs: 52,10000) .. controls (axis cs: 198,207) .. (axis cs: 199,5) -- (axis cs: 159,5) .. controls (axis cs: 159,166) .. (axis cs: 50,5371) -- cycle; \end{scope}

\end{axis}
\end{tikzpicture}

\end{document}

  • You have three separate paths. The even odd rule is used on one path(with self intersections or voids). I do not know the exact meaning of "fill the area between both paths"!? – hpekristiansen Oct 25 '23 at 20:36

1 Answers1

1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{nfold}
\makeatletter
\tikzset{offset/.code=\tikz@addmode{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymode=log, 
xmin=0, xmax=200, 
ymin=1, ymax=10000, 
grid=both,
]
\draw[save path=\mypath](52,10000) .. controls (198,207) .. (199,5) -- (159,5) .. controls (159,166) .. (50,5371) -- cycle;
\draw[red, thick, use path=\mypath, offset=-1pt, save path=\mypathA];
\draw[blue, thick, use path=\mypath, offset=-3pt, save path=\mypathB];
\fill[even odd rule, use path=\mypathA \mypathB];
\end{axis}
\end{tikzpicture}
\end{document}

Graph with ring shape and filled area

  • use path=\mypathA \mypathB isn't really right (a path picture would not be clipped correctly). Better to define \tikzset{append path/.code=\tikz@addmode{\expandafter\pgfsyssoftpath@addtocurrentpath\expandafter{#1}}} and then use use path=\mypathA, append path=\mypathB or append path/.list={\mypathA, \mypathB} even. – Qrrbrbirlbel Oct 25 '23 at 22:27