# Fill the common region by color

MWE:

\documentclass[12pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
\definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
%ymajorgrids=true,
%xmajorgrids=true,
xmin=-7.0,
xmax=7.0,
ymin=-7.0,
ymax=7.0,
xtick={-6,-5,-4,-3,...,6},
ytick={-6,-5,-4,-3,...,6},]
\clip(-5.,-5.) rectangle (6.,6.);
\draw [samples=50,rotate around={-90:(0,0)},xshift=0cm,yshift=0cm,line width=1pt,color=sexdts,domain=-8:8] plot (\x,{(\x)^2/2/2});
\draw [samples=50,rotate around={0:(0,0)},xshift=0cm,yshift=0cm,line width=1pt,color=rvwvcq,domain=-8:8] plot (\x,{(\x)^2/2/2});
\begin{scriptsize}
\draw [fill=black] (4,4) circle (3.0pt);
\draw[color=black] (4.8,3.5) node[left,above] {$A(4 , 4)$};
\draw [fill=black] (0,0) circle (3.0pt);
\draw[color=black] (0.9,-0.5) node [right,below,rotate=00]{$O(0 , 0)$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}


Question: How can i fill the common region (that means between (0 , 0) and (4 , 4)) with color?

One more Question: I want to draw arrows on both the negative axes as well as four tails of these two curve. Is it possible?

• With fill between, page 430 of the pgfplots manual – AndréC Oct 25 '18 at 10:03

## 1 Answer

Solution to first question with fillbetween library:

1. Load fillbetween library
2. Add name path to each involved line
3. Add fillbetween plot

This is what was done here:

\documentclass[12pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\pagestyle{empty}
\begin{document}
\definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882}
\definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
>=stealth,
x=1cm,y=1cm,
axis lines=middle,
axis line style={stealth-stealth},
%ymajorgrids=true,
%xmajorgrids=true,
xmin=-7.0,
xmax=7.0,
ymin=-7.0,
ymax=7.0,
xtick={-6,-5,-4,-3,...,6},
ytick={-6,-5,-4,-3,...,6},]
\clip(-5.,-5.) rectangle (6.,6.);
\addplot[samples=50,rotate around={-90:(0,0)},xshift=0cm,yshift=0cm,line width=1pt,color=sexdts,domain=-8:8, name path=A] plot (\x,{(\x)^2/2/2});
\addplot[samples=50,rotate around={0:(0,0)},xshift=0cm,yshift=0cm,line width=1pt,color=rvwvcq,domain=-8:8, name path=B] plot (\x,{(\x)^2/2/2});
\addplot[orange] fill between [of=A and B, soft clip={(0,0) rectangle (4,4)}];
\begin{scriptsize}
\draw [fill=black] (4,4) circle (3.0pt);
\draw[color=black] (4.8,3.5) node[left,above] {$A(4 , 4)$};
\draw [fill=black] (0,0) circle (3.0pt);
\draw[color=black] (0.9,-0.5) node [right,below,rotate=00]{$O(0 , 0)$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}


The result, looks like:

• Happy with this solution. But what about arrows? Which i want to draw at negative x-axis and y-axis even at tails of parabolas – Maths4Sandy Oct 26 '18 at 4:33
• Please help me. --> this type of arrow – Maths4Sandy Oct 26 '18 at 4:47
• See the desirable output image which i added in my question. – Maths4Sandy Oct 26 '18 at 6:35
• Try using \addplot[<->]. – Thevesh Theva Oct 26 '18 at 6:39
• @Thevesh Would you please explain in details? – Maths4Sandy Oct 26 '18 at 6:54