To Shade the Area Between $x^2$ and $\sqrt{x}$

by caffeinemachine   Last Updated June 23, 2018 14:23 PM

I want to draw the following image in tikZ

enter image description here

Basically I want to draw the boundary of the unit square, plot the x^2 and \sqrt x functions, and shade the area between them.

In my attempt to draw the two curves, I tried this

  \usepackage{pgfplots}
  \pgfplotsset{compat=1.10}
  \usepgfplotslibrary{fillbetween}
  \usetikzlibrary{patterns}
  \pgfplotsset{ticks=none}

  \begin{figure}[H]
  \centering
  \begin{tikzpicture}
  \begin{axis}[axis lines=middle,]
  \addplot[name path=F,black,domain={0:5}] {sqrt x};
  \addplot[name path=G,black,domain={0:5}] {x^2};
  \end{axis}
  \end{tikzpicture}
  \end{figure}

But the output I am getting is

enter image description here

Somehow the \sqrt{x} function is getting flattened out.

Also, how to get rid of the arrows I have in the axes and make an enclosing box like I have in the hand-drawn picture.



Related Questions


Problem with fill between option in pgfplots

Updated April 19, 2015 21:10 PM

Scaling problem with fillbetween in pgfplots

Updated July 28, 2015 16:47 PM

PGFPlots - Fill area between two curves

Updated July 11, 2017 10:23 AM

Shading a region to the left of a parabola

Updated August 10, 2017 15:23 PM

Plot changing abruptly when `xmin` is changed slightly

Updated September 25, 2017 07:23 AM