根据建议,我将拆分我之前的(多个)问题分成不同的部分。
我想要阴影覆盖曲线下方的部分区域,但是使用填充的矩形会导致(当然)曲线顶部被阴影覆盖(不应该这样),而底部不被阴影覆盖(应该这样)。
我的代码是
\documentclass{article}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat = newest}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis x line=bottom,
axis y line=left,
axis y discontinuity=crunch,
xmin=0,xmax=1.3,
ymin=0.5,ymax=1.3]
\addplot[
domain = 0:sqrt(1/3),
samples =200,
] {sqrt(7/6-x^2)};
\addplot[
domain = sqrt(1/3):sqrt(7/6),
fill = gray,
fill opacity = 0.1,
samples =200,
y filter/.expression={x==sqrt(7/6 )?0:y},
] {sqrt(7/6-x^2)}\closedcycle;
\addplot[
domain = 0:7,
samples =200,
] {sqrt(5/6)};
\fill[gray, opacity = 0.1] (0,0) -- (0,0.9129) -- (0.5774,0.9129) -- (0.5774,0);
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis x line=bottom,
axis y line=left,
axis y discontinuity=crunch,
xmin=0, xmax=1.3,
ymin=0.5, ymax=1.3,
y axis line style={name path=yaxis},
]
\addplot[
name path=circ,
domain=0:sqrt(7/6-1/4),
samples=200,
] {sqrt(7/6-x^2)};
\addplot[gray] fill between [of=yaxis and circ, reverse=false, soft clip={(-1,-1) rectangle (1,{sqrt(5/6)})}, on layer={axis background}];
\draw (0,{sqrt(5/6)}) -- (1.3,{sqrt(5/6)});
\draw ({sqrt(1/3)},0.5) -- ({sqrt(1/3)},{sqrt(5/6)});
\end{axis}
\end{tikzpicture}
\end{document}