-2

This question already has an answer here:

I want to fill integral limits by exponent function y=e^{x-1}; y=2-x, and Ox. Please everybody help![enter image description here]1

marked as duplicate by Andrew Swann, Bobyandbob, Troy, flav, Sebastiano May 18 '18 at 9:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 7
    What you want to achieve is not very clear. Could you explain with some details? – Bernard May 14 '18 at 8:03
  • Please contextualize because we cannot read your mind. – gvgramazio May 14 '18 at 8:48
  • \documentclass{standalone}\usepackage{pgfplots}\pgfplotsset{compat=1.9}\usepgfplotslibrary{fillbetween} \begin{document} \begin{tikzpicture} \begin{axis}[axis on top,set layers] \addplot[blue,name path=A,domain=0:2.3] {2-x)}; \addplot[red,name path=B,domain=0:2.3] {exp(x-1)}; \pgfonlayer{pre main} \fill[blue!20!white,intersection segments={of=B and A}] -- (axis cs:2.3,\pgfkeysvalueof{/pgfplots/ymin}) -- (axis cs:0,\pgfkeysvalueof{/pgfplots/ymin}) -- cycle; \endpgfonlayer \end{axis} \end{tikzpicture} \end{document} – Bobyandbob May 14 '18 at 9:02
  • ... your question is a duplicate to Fill the area under minimum of two functions using tikz and pgfplots. Above i just changed this part \addplot[blue,name path=A,domain=0:2.3] {2-x}; \addplot[red,name path=B,domain=0:2.3] {exp(x-1)}; \pgfonlayer{pre main} \fill[blue!20!white,intersection segments={of=B and A}] to your needs. – Bobyandbob May 14 '18 at 9:05
6

First, you should post what you tried, and then, you post your question.

\documentclass[a4paper, 12pt]{standalone}
\usepackage{fouriernc}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}
    [
    axis lines = center,
    axis line style = very thick,
    xlabel=$x$, ylabel=$y$,
    domain=-1:3,
    ymin=-0.5,
    ymax=2.5,
    xmin=-1,
    xmax=3,
    xticklabels={},yticklabels={},
    unit vector ratio*=1 1 1,
    width=7cm,
    grid=major,
    grid style={gray!30}
    ]
\addplot [name path=A,blue, very thick,samples=100] {exp(x-1)};
\addplot [name path=B,thick] {2-x};
\addplot [name path=C] {0};
\node at (axis cs:-0.25, -0.25) {$O$} ;
\addplot [black, mark = *] coordinates {(1, 1)} ;
\addplot[pattern=north east lines] fill between[of=A and C,soft clip={domain=0:1}];
\addplot[pattern=north east lines] fill between[of=B and C,soft clip={domain=1:2}];
\addplot[color=blue,dashed] coordinates {
            (0, 1)
            (1, 1)
            (1,0 )
               };
\node at (axis cs:-0.2, 1) {$1$} ;
\node at (axis cs:1, -0.25) {$1$} ;
       \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

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