无法使用 tikz 突出显示 $x^2+y^2=2x ; x=y^2$ 的交点区域

无法使用 tikz 突出显示 $x^2+y^2=2x ; x=y^2$ 的交点区域

我无法$x^2+y^2=2x ; x=y^2$使用突出显示的交叉区域TikZ,我已尝试使用两种不同的代码pgfonlayer,如下所示,一种正在运行,但输出为三角形形式的填充阴影,另一种没有运行,我已在下面的评论中显示。

请帮忙...谢谢

\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}

答案1

\fill命令只能作用于封闭区域,例如(0, 0) -- (1, 1) -- (1, 2) -- (0, 0)。如果您为其提供未封闭的坐标列表,则(0, 0) -- (1, 1) -- (1, 2)它会自动链接最后一个和第一个坐标以形成一个封闭的坐标列表。请参阅 pgf 手册第 15.5 节。

在您的示例中,\fill[red] plot[smooth,domain= -2:2,variable=\y] ({(\y)^2},\y);形成一个坐标列表,以 开始(4, -2)并以 结束(4, 2)。因此,tikz 链接这两个坐标以形成一个封闭区域,然后填充它。

以你为例,

\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}

在此处输入图片描述

更新

填充区域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}

在此处输入图片描述

答案2

考虑一下我对您上一个问题的回答,即使用pgfplots.fillbetween库和附加项positioning,看看以下 MWE 是否可以接受:

\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}

在此处输入图片描述

附录: 您的评论完全改变了您的问题。考虑到这一点,可能的解决方案是:

\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}

在此处输入图片描述

相关内容