0

I am unable to highlight the intersection area of $x^2+y^2=2x ; x=y^2$ using TikZ, I have tried two different codes by using pgfonlayer, as mentioned below, one is running but giving output as filling shade in the form of triangle, other is not running which I have shown below in comments.

Please help... thanks

\documentclass{article}
\usepackage{tikz,pgfplots}
%\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg}    % declare background
\pgfsetlayers{bg,main}  % order of layers (main = standard layer)
\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}





\begin{document}




\begin{tikzpicture}


\draw(1,0)circle(1cm); % DRAW CIRCLE
\draw[blue,line width = 0.50mm]   plot[smooth,domain= -2:2,variable=\y]
( {(\y)^2},\y); 
\draw (-2,0)--(4,0) (0,-2)--(0,4);
\draw(1,1)node(a){A}--(1,0)node(c){C};
\draw(2,0)node(b){B}--(0,0)node(o){O};


\begin{pgfonlayer}{bg}    % select background
\path [fill=blue!50] (o.center) --(a.center) --(b.center) -- cycle;

\end{pgfonlayer}

I have tried the following code as well, but it is showing some error, please help. 
%   \begin{pgfonlayer}{bg}    % select background
%   \clip plot[smooth,domain=0:2] (\sqrt{1-(x-1)^2}, \x);
%   \fill[red]  plot[smooth,domain= -2:2,variable=\y] ({(\y)^2},\y);
%   \end{pgfonlayer}
\end{tikzpicture}

\end{document}
2

The \fill command can only act on a closed area, for example (0, 0) -- (1, 1) -- (1, 2) -- (0, 0). If you give it an unclosed coordinate list, say (0, 0) -- (1, 1) -- (1, 2) then it auto links the last and first coordinates to form a closed one. See pgf manual, Sec. 15.5.

In your example, \fill[red] plot[smooth,domain= -2:2,variable=\y] ({(\y)^2},\y); forms a coordinate list begins from (4, -2) and ends with (4, 2). So tikz links these two coordinates to form a closed area and then fills it.

With your example,

\documentclass{article}
\usepackage{tikz,pgfplots}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg}    % declare background
\pgfsetlayers{bg,main}  % order of layers (main = standard layer)
\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\draw(1,0)circle(1cm); % DRAW CIRCLE
\draw[blue,line width = 0.50mm]   plot[smooth,domain= -2:2,variable=\y]
( {(\y)^2},\y); 
\draw (-2,0)--(4,0) (0,-2)--(0,4);
\draw(1,1)node(a){A}--(1,0)node(c){C};
\draw(2,0)node(b){B}--(0,0)node(o){O};


\begin{pgfonlayer}{bg}    % select background
  \path [fill=blue!50] (o.center) --(a.center) --(b.center) -- cycle;
\end{pgfonlayer}

\begin{pgfonlayer}{bg}    % select background
 \fill[red]  
    plot[smooth,domain=0:1,variable=\y] ({(\y)^2},\y)  % (0, 0) to (1, 1)
    arc[start angle=90, end angle=180, radius=1];      % (1, 1) to (0, 0), hence closed
 \fill[red]  
    plot[smooth,domain=0:-1,variable=\y] ({(\y)^2},\y) % (0, 0) to (1, -1)
    arc[start angle=270, end angle=180, radius=1];     % (1, -1) to (0, 0), hence closed
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

enter image description here

Update

To fill the area O-(x=y^2)-A-(circle)-B-(line)-O:

\documentclass{article}
\usepackage{tikz,pgfplots}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg}    % declare background
\pgfsetlayers{bg,main}  % order of layers (main = standard layer)
\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\draw(1,0)circle(1cm); % DRAW CIRCLE
\draw[blue,line width = 0.50mm]   plot[smooth,domain= -2:2,variable=\y]
( {(\y)^2},\y); 
\draw (-2,0)--(4,0) (0,-2)--(0,4);
\draw(1,1)node(a){A}--(1,0)node(c){C};
\draw(2,0)node(b){B}--(0,0)node(o){O};


\begin{pgfonlayer}{bg}    % select background
  \path [fill=blue!50] (o.center) --(a.center) --(b.center) -- cycle;
\end{pgfonlayer}

\begin{pgfonlayer}{bg}    % select background
 \fill[red]  
    plot[smooth,domain=0:1,variable=\y] ({(\y)^2},\y) % (0, 0) to (1, 1)
    arc[start angle=90, end angle=0, radius=1];       % (1, 1) to (2, 0)
                                      % tikz auto links (2, 0) and (0, 0)
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

enter image description here

|improve this answer|||||
  • Thanks for your help, but I need to fill color n the area OABCO , which includes the inner side of the parabola and circle. Please help on this how to fill this area, as I am getting the area filled like triangle as shown in the figure. – sultan Mar 28 at 12:52
  • @sultan Updated my answer. Not sure if I correctly understand your requirement. – muzimuzhi Z Mar 28 at 19:47
  • This is perfectly what I required.. thanks a lot... was unable to trace the correct path.. this is perfectly fine..... thanks a lot once again... God bless you.. – sultan Mar 29 at 4:08
2

Consider my answer on your previous question, i.e. use pgfplots.fillbetween library and additional positioning, see if the following MWE is acceptable for you:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{backgrounds,
                pgfplots.fillbetween,
                intersections,
                positioning
                }

\begin{document}
    \begin{tikzpicture}[%scale = 0.75, 
dot/.style={circle,fill,inner sep=1pt}
                        ]
\draw (-0.5,0) -- (4,0.0);
\draw (0,-2.5) -- (0,2.5);

\draw[name path=A, blue!60, line width=0.5mm]   
    plot[domain= -2:2, smooth, variable=\y]   (\y*\y,\y);
\draw[name path=B]  (1,0) circle[radius=10mm];
\draw[name intersections={of=A and B, by={a,b,c}},
      densely dashed, very thin]    (c) node[above] {A} -- (b -| c)
                                        node[below] {C}
                                    (b) node[below left] {O};
\coordinate[right=2 of b, label=below:B] (B);
\scoped[on background layer]
{
\fill[blue!30] (b) -- (c) -- (B);
\clip (a) rectangle (b |- c);
\tikzfillbetween[of=A and B]{orange!30};
}
    \end{tikzpicture}
\end{document}

enter image description here

Addendum: with your comment you completely change your question. Considering it, possible solution is:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{backgrounds,
                intersections,
                positioning
                }

\begin{document}
    \begin{tikzpicture}[%scale = 0.75,
dot/.style={circle,fill,inner sep=1pt}
                        ]
\draw (-0.5,0) -- (4,0.0);
\draw (0,-2.5) -- (0,2.5);

\draw[name path=A, blue!60, line width=0.5mm]
    plot[domain= -2:2, smooth, variable=\y]   (\y*\y,\y);
\draw[name path=B]  (1,0) circle[radius=10mm];
\draw[name intersections={of=A and B, by={a,b,c}},
      densely dashed, very thin]    (c) node[above] {A} -- (b -| c)
                                        node[below] {C}
                                    (b) node[below left] {O};
\coordinate[right=2 of b, label=below:B] (B);

\scoped[on background layer]
{
\fill[orange!30]   
    plot[domain=0:1, smooth, variable=\y] (\y*\y,\y) arc(90:0:1);
}
    \end{tikzpicture}
\end{document}

enter image description here

|improve this answer|||||
  • Thanks for your help, but I need to fill color n the area OABCO , which includes the inner side of the parabola and circle. Please help on this how to fill this area, as I am getting the area filled like triangle as shown in the figure. – sultan Mar 28 at 12:52
  • @sultan, this was not stated in your question. There you ask for solution provided by (first version of) my answer. See addendum to answer. – Zarko Mar 29 at 6:41

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