我正在尝试制作这个图表。 通过阅读,我得到了有关在两个函数之间阴影化内部部分的信息,但就我而言,它们都不是函数。我尝试执行以下操作,但没有成功。
代码:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:3,axis lines=middle,xlabel=$x$,ylabel=$y$,clip=false,
xtick=\empty,ytick=\empty,unit vector ratio=1 1 1]
\addplot[color=red,thick,name path=A] {sqrt(x)} node[right] {$y =\sqrt{x}$};
\addplot[color=red,thick,name path=A] {-sqrt(x)} node[right] {$y =-\sqrt{x}$};
\addplot[color=blue,thick,name path=B] {sqrt(9-x^2)} node[right] {$y=\sqrt{9-x^2}$};
\addplot[cyan] fill between [of=B and A];
\end{axis}
\end{tikzpicture}
\end{document}
答案1
像这样?
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{pgfplots.fillbetween}
\begin{document}
\begin{tikzpicture}
\draw[draw=red, fill=red!10, dashed, semithick]
(0,0) circle[radius=3cm];
\node at (135:2) {$x^2 + y^2 < 9$};
\draw[smooth, blue,thick, name path=A]
plot[samples at={0,0.025,...,0.5,1,...,4}] (\x,{ sqrt(\x)}) node[below=1em] {$x - y^2\geq 0$};
\draw[smooth, blue,thick, name path=B]
plot[samples at={0,0.025,...,0.5,1,...,4}] (\x,{-sqrt(\x)});
\tikzfillbetween[of=A and B]{fill=cyan, fill opacity=0.3};
% axis
\draw[->] (-4,0) -- ++ (9,0) node [below left] {$x$};
\draw[->] (0,-4) -- ++ (0,8) node [below left] {$y$};
\foreach \i in {0,90,180,270}
{
\ifnum\i<180
\node[above right] at (\i:3) {$3$};
\else
\node[below left] at (\i:3) {$-3$};
\fi
}
%
\end{tikzpicture}
\end{document}
答案2
parabola
pgfmanual 文档第 14.9 节“抛物线操作”的替代方案。
\draw [rotate=-90,blue,thick,fill=blue!10](-4,4) parabola[bend pos=0.5] bend +(0,-4) +(8,0);
然后\clip
我们再次为抛物线的内部着色
\begin{scope}
\path[clip] (0,0) circle (3);
\draw [rotate=-90,blue,thick,fill=red!20](-4,4) parabola[bend pos=0.5] bend +(0,-4) +(8,0);
\end{scope}
代码
\documentclass[margin=3mm]{standalone}
%https://tex.stackexchange.com/questions/684350/fill-between-relations
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[densely dashed,red, fill=red!10] (0,0) circle (3);
\node at (135:4) {$x^2 + y^2 < 9$};
%%%%%%%%%%%%%%%%%%%%%%% alternative
% \draw [rotate=-90,blue,thick,fill=cyan](-2,4) parabola[bend pos=0.5] bend +(0,-4) +(4,0);
\draw [rotate=-90,blue,thick,fill=blue!10](-4,4) parabola[bend pos=0.5] bend +(0,-4) +(8,0);
\begin{scope}
\path[clip] (0,0) circle (3);
% \draw [rotate=-90,blue,thick,fill=red!20](-2,4) parabola[bend pos=0.5] bend +(0,-4) +(4,0);
\draw [rotate=-90,blue,thick,fill=red!20](-4,4) parabola[bend pos=0.5] bend +(0,-4) +(8,0);
\end{scope}
\node [right] at (4,2.5) {$x - y^2\geq 0$};
% % axis
\draw[->,>=latex] (-4,0) -- ++ (9,0) node [below left] {$x$};
\draw[->,>=latex] (0,-4) -- ++ (0,8) node [below left] {$y$};
%
\node[below left] at (-3,0) {$-3$};
\node[below right] at (3,0) {$3$};
\node[above left] at (0,3) {$3$};
\node[below left] at (0,-3) {$-3$};
%
\end{tikzpicture}
\end{document}