# Fill area between wave-lines

I want to draw a diagram in which one bar is too large to fit in the axis. So I want to indicate this by "cutting" the bar with two parallel wavelines.

My approach was to

1. draw the diagram with the bars, then
2. draw the wave-lines and
3. fill the space between the lines white.

The big question is: how?
Can I specify all four intersections and fill this path?

MWE:

\begin{tikzpicture}[scale=0.5, >=Stealth]
% x-Achse
\draw[->]
(-4, 0) --  (6.5, 0)
node[right] (x) at  (6.5, 0){$x$};

% y-Achse
\draw[->]
(0, -7) --  (0, 4.5)
node[right] (y) at  (0, 4){$\rho$};
\draw[thick]
(-0.125, 3) --  (0.125, 3)
node[left]  (edn)   at  (-0.125, 3){$eD_N$};

% right area
\draw
(0,0)   rectangle (4, 3);
\fill[pattern=north west lines]
(0,0)   rectangle (4, 3);

\fill[color=white]
% +
\draw
(2, 1.5) circle (8pt)
node[] (+) at(2, 1.5){\textbf{+}};
% -------------------------------------------

% left area
\draw
(0,0)   rectangle (-0.5, -6);
\fill[pattern=north west lines]
(0,0)   rectangle (-0.5, -6);

\fill[color=white]
% -
\draw
(-0.25, -2) circle (6pt)
node[] (+) at(-0.25, -2.1){\textbf{-}};

% Wavelines
\draw[decorate, decoration={snake, amplitude=0.4mm, segment length=2.5mm}, name path = oben]
(-0.6, -3)  --  (0.1, -3);
\draw[decorate, decoration={snake, amplitude=0.4mm, segment length=2.5mm}, name path = unten]
(-0.6, -3.3)--  (0.1, -3.3);
(-0.6, -3)  --  (-0.6, -3.3);
\draw[color=white, name path = rechts]
(0.1, -3)   --  (0.1, -3.3);
% \fill[white, intersection segments={of=oben and unten}]; % ??

% -------------------------------------------

\end{tikzpicture}

• I've updated my answer with an easier alternative. – Ignasi Nov 15 '17 at 20:17

As an alternative you could consider drawing the left part with two tape nodes.

This nodes accept a minimum width parameter but not minimum height, therefore I've forced their size with a phantom \rule as node contents.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning, arrows.meta, patterns, decorations.pathmorphing, intersections, shapes.symbols}

\begin{document}
\begin{tikzpicture}[scale=0.5, >=Stealth]
% x-Achse
\draw[->]
(-4, 0) --  (6.5, 0)
node[right] (x) at  (6.5, 0){$x$};

% y-Achse
\draw[->]
(0, -7) --  (0, 4.5)
node[right] (y) at  (0, 4){$\rho$};
\draw[thick]
(-0.125, 3) --  (0.125, 3)
node[left]  (edn)   at  (-0.125, 3){$eD_N$};

% right area
\draw
(0,0)   rectangle (4, 3);
\fill[pattern=north west lines]
(0,0)   rectangle (4, 3);

\fill[color=white]
% +
\draw
(2, 1.5) circle (8pt)
node[] (+) at(2, 1.5){\textbf{+}};
% -------------------------------------------

\node[tape, draw, tape bend top=none,
shape border rotate=90, minimum width=5mm,
inner sep=0pt, transform shape,
below left=0pt of {(0,0)},
pattern=north west lines] (tape1) at (0,0) {\rule{0pt}{2.9cm}};

\node[tape, draw, tape bend bottom=none,
shape border rotate=90,
minimum width=5mm,
inner sep=0pt,
transform shape,
below = 3mm of tape1,
pattern=north west lines] {\rule{0pt}{2.8cm}};

% left area
%            \draw
%                        (0,0)   rectangle (-0.5, -6);
%            \fill[pattern=north west lines]
%            (0,0)   rectangle (-0.5, -6);

\fill[color=white]
% -
\draw
(-0.25, -2) circle (6pt)
node[] (+) at(-0.25, -2.1){\textbf{-}};

% -------------------------------------------

\end{tikzpicture}
\end{document}

Update:

AboAmmar's solution remind me the option of using a double line, which is easier than my previous tapenodes:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning, arrows.meta, patterns, decorations.pathmorphing, intersections, shapes.symbols}

\begin{document}
\begin{tikzpicture}[scale=0.5, >=Stealth]
% x-Achse
\draw[->]
(-4, 0) --  (6.5, 0)
node[right] (x) at  (6.5, 0){$x$};

% y-Achse
\draw[->]
(0, -7) --  (0, 4.5)
node[right] (y) at  (0, 4){$\rho$};
\draw[thick]
(-0.125, 3) --  (0.125, 3)
node[left]  (edn)   at  (-0.125, 3){$eD_N$};

% right area
\draw
(0,0)   rectangle (4, 3);
\fill[pattern=north west lines]
(0,0)   rectangle (4, 3);

\fill[color=white]
% +
\draw
(2, 1.5) circle (8pt)
node[] (+) at(2, 1.5){\textbf{+}};
% -------------------------------------------

% left area
\draw
(0,0)   rectangle (-0.5, -6);
\fill[pattern=north west lines]
(0,0)   rectangle (-0.5, -6);

\fill[color=white]
% -
\draw
(-0.25, -2) circle (6pt)
node[] (+) at(-0.25, -2.1){\textbf{-}};

% Wavelines
\draw[double]
(-0.6,-3)..controls(-.45,-2.9)..(-.25,-3)..controls(-.05,-3.1)..(0.1,-3)
\end{tikzpicture}
\end{document}

I'd use simple paths instead of complicated intersections and decorations. First, compose a closed path using ()..controls()..() and fill it white. Then, repeat the two waves using the same ()..controls()..() operation.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,patterns}
\begin{document}

\begin{tikzpicture}[scale=0.5, >=Stealth]
% x-Achse
\draw[->]
(-4, 0) --  (6.5, 0)
node[right] (x) at  (6.5, 0){$x$};

% y-Achse
\draw[->]
(0, -7) --  (0, 4.5)
node[right] (y) at  (0, 4){$\rho$};
\draw[thick]
(-0.125, 3) --  (0.125, 3)
node[left]  (edn)   at  (-0.125, 3){$eD_N$};

% right area
\draw
(0,0)   rectangle (4, 3);
\fill[pattern=north west lines]
(0,0)   rectangle (4, 3);

\fill[color=white]
% +
\draw
(2, 1.5) circle (8pt)
node[] (+) at(2, 1.5){\textbf{+}};
% -------------------------------------------
% left area
\draw
(0,0)   rectangle (-0.5, -6);
\fill[pattern=north west lines]
(0,0)   rectangle (-0.5, -6);

\fill[color=white]
% -
\draw
(-0.25, -2) circle (6pt)
node[] (+) at(-0.25, -2.1){\textbf{-}};

% White fill
\path[fill=white](-0.6,-3)..controls(-.45,-2.9)..(-.25,-3)..controls(-.05,-3.1)..(0.1,-3)
--(0.1,-3.3)..controls(-.05,-3.4)..(-.25,-3.3)..controls(-.45,-3.2)..(-.6,-3.3)--cycle;
% Wavelines
\draw(-0.6,-3)..controls(-.45,-2.9)..(-.25,-3)..controls(-.05,-3.1)..(0.1,-3)
(0.1,-3.3)..controls(-.05,-3.4)..(-.25,-3.3)..controls(-.45,-3.2)..(-.6,-3.3);
% -------------------------------------------
\end{tikzpicture}

\end{document}

as supplement (again :-) ) to AboAmmar answer (with slightly shorter and different code -- removed is all clutter in op code -- but with the same base idea):

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta,
patterns}
\usepackage{bm}

\begin{document}
\begin{tikzpicture}[scale=0.5, >=Stealth,
sign/.style = {midway, circle, fill=white, inner sep=0pt, font=\scriptsize}
]
% axis
\draw[->]       (-4, 0) -- (6.5,0) node[right] {$x$};
\draw[->]       ( 0,-7) -- (0,4.5) node[below right]    {$\rho$};
% tick
\draw[thick]  (0.1,3) -- +(-0.2,0) node[left] {$eD_N$};
% right area
\filldraw[pattern=north west lines]
(0,0)   rectangle (4,3) node[sign] {$\bm{+}$};
% left area
\filldraw[pattern=north west lines]
(0,0)   rectangle (-0.5,-6) node[sign,above=2mm] {$\bm{-}$};
% Wavelines
\fill[white]
(0.2,-4) .. controls + (-0.2,-0.2) and + (0.2,0.2) ..  ++ (-0.9,0) -- ++ (0,-0.2)
.. controls + (0.2,0.2) and + (-0.2,-0.2) ..  ++ ( 0.9,0) -- cycle;
\draw
(0.2,-4) .. controls + (-0.2,-0.2) and + (0.2,0.2) ..  ++ (-0.9,0)    ++ (0,-0.2)
.. controls + (0.2,0.2) and + (-0.2,-0.2) ..  ++ ( 0.9,0);
\end{tikzpicture}
\end{document}

You can use scope environment.

Here is the code to replace yours at the end

% Wavelines
\begin{scope}
\clip (-0.6, -2.9) -- (0.1, -2.9) -- (0.1, -3.4) -- (-0.6, -3.4) -- cycle;
\draw[color=white]
(-0.6, -2.8) -- (0.1, -2.8) -- (0.1, -3.8) -- (-0.6, -3.8) -- cycle;
\draw[fill=white, decorate, decoration={snake, amplitude=0.5mm, segment length=2.5mm}]
(-1.5, -3) -- (0.5, -3) -- (0.7, -3.4) -- (-1.5, -3.4) -- cycle;
\end{scope}