
Ich kann den Schnittpunkt der $x^2+y^2=2x ; x=y^2$
Verwendung nicht hervorheben TikZ
. Ich habe zwei verschiedene Codes mit ausprobiert pgfonlayer
. Wie unten angegeben, läuft einer, gibt aber eine Füllung in Form eines Dreiecks aus, der andere läuft nicht, wie ich unten in den Kommentaren gezeigt habe.
Bitte helfen Sie ... danke
\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}
Antwort1
Der \fill
Befehl kann nur auf einen geschlossenen Bereich wirken, z. B. (0, 0) -- (1, 1) -- (1, 2) -- (0, 0)
. Wenn Sie ihm eine offene Koordinatenliste geben, (0, 0) -- (1, 1) -- (1, 2)
verknüpft er automatisch die letzte und die erste Koordinate, um eine geschlossene zu bilden. Siehe pgf-Handbuch, Abschnitt 15.5.
In deinem Beispiel \fill[red] plot[smooth,domain= -2:2,variable=\y] ({(\y)^2},\y);
beginnt eine Koordinatenliste bei (4, -2)
und endet mit (4, 2)
. Tikz verknüpft also diese beiden Koordinaten zu einem geschlossenen Bereich und füllt diesen anschließend aus.
Mit Ihrem Beispiel,
\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}
Aktualisieren
So füllen Sie den Bereich 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}
Antwort2
Bedenken Sie meine Antwort auf Ihre vorherige Frage, d. h. verwenden Sie pgfplots.fillbetween
die Bibliothek und zusätzliche Informationen positioning
, und prüfen Sie, ob das folgende MWE für Sie akzeptabel ist:
\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}
Nachtrag: mit Ihrem Kommentar ändern Sie Ihre Frage komplett. In Anbetracht dessen ist eine mögliche Lösung:
\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}