15

probably an easy one for people how are used to it. i'd like to fill the area between the two functions with a pattern (stripes, for instance). See the code below. I saw something like this with [domain]-option, but no glue how the scheme works, maybe i'm totaly wrong :D

JOB:

fill diff between red and black funktion

Thanks so far

\def\dtwData{graphics/data/dtwSimple.txt}
\begin{tikzpicture}
%Points
\coordinate (x-start) at (0cm, 2cm);
\coordinate (x-end) at (15cm, 2cm);
\begin{scope}[thick]
    \draw[] (0,0) -- (0,6); 
    \draw[] (x-start) -- (x-end);
\end{scope}
\draw[color=red, thick] (0, 1) -- (14, 6);
\draw[color=blue, dashed] (0, 1.75) -- (14, 6.75);
\draw[color=blue, dashed] (0, 0.25) -- (14, 5.25);
%plot
\draw[thick] plot[smooth] file {\dtwData};
\end{tikzpicture}

enter image description here

7

You need to recreate the same paths, i.e. copy the code for the two \draw commands, and use the resulting path with the \fill option. Using \fill (0,1) -- (14,6) (0,0) plot[smooth] file {\dtwData} might do it. There are also some option which let you change the rules for filling a path which crosses itself. See the PGF manual for the details.

8

Here is my finial graphic, FYI

\def\dtwData{graphics/data/dtwSimple.txt}
\begin{tikzpicture}[scale=0.8]
    \coordinate (x-start) at (0cm, 2cm);
    \coordinate (x-end) at (15cm, 2cm);
    \begin{scope}[]
    \draw[-latex'] (0,0) -- (0,6);  
    \draw[-latex'] (x-start) -- (x-end);
    \draw (13.75,1.7) node[right] {\footnotesize $Zeit$};
    \draw (0,5.75) node[left] {\footnotesize $Wert$};
    \end{scope}
    \fill [color=gray!20, opacity=0.01] (0,0.25) -- (0, 1.75) -- (14, 6.75) -- (14, 5.25) ;
    \draw[color=gray, opacity=0.5] (0, 1.75) -- (14, 6.75);
    \draw[color=gray, opacity=0.5] (0, 0.25) -- (14, 5.25);
    %plot
    \draw[thick] plot[smooth] file {\dtwData};
    \fill[color = gray!60, opacity=0.1] (0,1) -- (14,6) (0,0) plot[smooth] file {\dtwData};
    \fill[pattern color = gray, pattern = north east lines, opacity=0.8] (0,1) -- (14,6) (0,0) plot[smooth] file {\dtwData};
    \draw[color=gray, thick] (0, 1) -- (14, 6);
    \draw[latex'-latex'] (14.15, 5.25) -- (14.15, 6.75);
    \draw (14.2, 6) node[right] {\footnotesize $Grenzen$};
    \draw[-latex'] (4, 5.75) to[out=0,in=90] (6.8, 3.45);
    \draw (3.8, 5.75) node[left, gray] {\footnotesize $Vorlage$};
    \draw[-latex'] (4, 5) to[out=0,in=90] (6, 3.4);
    \draw (3.8, 5) node[left] {\footnotesize $Vergleichsdaten$};
    \draw[-latex'] (11.3, 3) to[out=180,in=-90] (7.7, 3.5);
    \draw (11.5, 3) node[right] {\footnotesize $Differenz$};
\end{tikzpicture}

enter image description here

  • 2
    Why do you set the text labels in math mode? If you want to use italics then \textit would be better. – Martin Heller Jan 26 '13 at 21:55
  • It is quicker and in the final draw, there will be functions. :D – Alex Feb 3 '13 at 15:08
  • 1
    @Alex It's also wrong to use $ for italics, and it looks bad (see Differenz in particular). If all nodes should be in italic, every node/.style={font=\itshape}. (And yes, I know answer is two and a half years old.) – Torbjørn T. Jun 26 '15 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.