Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
3  
Possible duplicate: Fill the area between two curves calculated by pgfplots –  Benedikt Bauer Jan 26 '13 at 12:28
1  
AFAIK you need to recreate the same paths, i.e. copy the code for the two \draw commands. Try \fill (0,1) -- (14,6) (0,0) plot[smooth] file {\dtwData}. –  Martin Scharrer Jan 26 '13 at 12:28
    
Thanks, the trick @MartinScharrer worked. The ohter thread is informative as well (at)Benedikt, if found right now an ohter variation fill between two curves in pgfplots –  Alex Jan 26 '13 at 12:36
    
@Alex: Ok, in this case I posted my comment as an answer. If you accept it the question gets marked as concluded. –  Martin Scharrer Jan 26 '13 at 13:23
add comment

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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