4

I want to fill up the area of the bounded region of the two curves by pattern lines.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
 \begin{tikzpicture}
 \draw [cyan, xshift=0cm] plot [smooth, tension=1] coordinates { (0,1.5) (0.7,2.3) (1.6,1.1) (2.5,1.9)   (3,2)};

 \draw [cyan, xshift=0cm] plot [smooth, tension=1] coordinates { (0,2.5) (0.4,2.4) (1,1) (2.4,2.6) (2.7,0.9) (3,1)};
 %\draw [thin, dashed,draw=gray!50!blue!30] (0,0) grid (3,3);
 \draw (0,3)--(0,0)node[below]{$0$} --(3,0)node[below]{$1$}--(3,3);
 \end{tikzpicture}
 \end{document}  

enter image description here

I have found some example from Graphics: Area between curves. But failed in this case. How can I do this?

4

You mean something like (inspired by this):

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
 \begin{tikzpicture}
 \draw [cyan, xshift=0cm, name path=one] plot [smooth, tension=1] coordinates { (0,1.5) (0.7,2.3) (1.6,1.1) (2.5,1.9)   (3,2)};

 \draw [cyan, xshift=0cm,name path=two] plot [smooth, tension=1] coordinates { (0,2.5) (0.4,2.4) (1,1) (2.4,2.6) (2.7,0.9) (3,1)};
 %\draw [thin, dashed,draw=gray!50!blue!30] (0,0) grid (3,3);
 \draw (0,3)--(0,0)node[below]{$0$} --(3,0)node[below]{$1$}--(3,3);
  \tikzfillbetween[
    of=one and two,split
  ] {pattern=grid};
 \end{tikzpicture}
 \end{document}  

enter image description here

EDIT

To change the pattern simply change the pattern value in the tikzfillbetween command, ie

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
 \begin{tikzpicture}
 \draw [cyan, xshift=0cm, name path=one] plot [smooth, tension=1] coordinates { (0,1.5) (0.7,2.3) (1.6,1.1) (2.5,1.9)   (3,2)};

 \draw [cyan, xshift=0cm,name path=two] plot [smooth, tension=1] coordinates { (0,2.5) (0.4,2.4) (1,1) (2.4,2.6) (2.7,0.9) (3,1)};
 %\draw [thin, dashed,draw=gray!50!blue!30] (0,0) grid (3,3);
 \draw (0,3)--(0,0)node[below]{$0$} --(3,0)node[below]{$1$}--(3,3);
  \tikzfillbetween[
    of=one and two,split
  ] {pattern=north west lines};
 \end{tikzpicture}
 \end{document}  

for

enter image description here

| improve this answer | |
  • thanks for your answer. How can I change pappern style? @Moriambar – MKS May 10 '17 at 19:24
  • @MdKutubuddinSardar you have to change the pattern value, as I indicated in the edit. To see which pattern to use, I suggest you browse through tikz documentation – Moriambar May 10 '17 at 19:28

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.