I am trying to draw this graph with latex, but I can't find a way to add the B point and the y = x^2 and y = x labels:

I did this:

using this code:

\documentclass[]{book}
\usepackage{systeme, microtype, amsmath, pgfplots, geometry}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\let\ds\displaystyle
\begin{document}

\tikz[scale=0.75,domain=-0.1:1.1,samples=50]{
    \begin{axis}[axis x line=middle, axis y line=middle, stack plots=y]
        \addplot+[mark=none] {x};
        \addplot+[mark=none, fill=green, fill opacity=0.25] {min(x^2 - (x), 0)} \closedcycle;
    \end{axis}
}

\end{document}

Can anyone help me?

up vote 1 down vote accepted

I also found the default positions of the x and y axis labels a bit unfortunate so I placed them, more or less, manually. By adjusting the anchors you'll be able to move them around. And I removed all packages that were not necessary.

\documentclass[]{book}
\usepackage{pgfplots,geometry}
\pgfplotsset{compat=1.16}
\begin{document}

\tikz[scale=0.75,domain=-0.1:1.1,samples=50]{
    \begin{axis}[axis x line=middle, axis y line=middle, stack plots=y]
        \addplot+[mark=none] {x};
        \addplot+[mark=none, fill=green, fill opacity=0.25] {min(x^2 - (x), 0)} \closedcycle;
    \node[circle,fill,scale=0.3,label=right:$B$] at (axis cs:1,1){};
    \node[anchor=south west] at (axis cs:0.75,0.5){$y=x^2$};
    \node[anchor=south east] at (axis cs:0.5,0.5){$y=x$};
    \end{axis}
    \node[anchor=south east,scale=0.75] at (current axis.right of origin) {$x$};
    \node[anchor=north west,scale=0.75] at (current axis.above origin) {$y$};
}

\end{document}

enter image description here

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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