在下面的代码中,我遇到了问题:
\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,
xlabel=,
ylabel=,
enlargelimits,
ytick=\empty,
xtick={-1.19,2.38},
xticklabels={$-1$,$2$}]
\addplot[name path=F,blue,domain={-1.19:4}] {-(1/6)*x^2+2};
\addplot[name path=G,green,domain={-3:4}] {0.25*x^2};
\addplot[pattern=north west lines, pattern color=brown!50]fill between[of=F and G, soft clip={domain=-2.19:2.19}]
;
\end{axis}
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,
xlabel=,
ylabel=,
enlargelimits,
ytick=\empty,
xtick={-1.19,2.38},
xticklabels={$-1$,$2$}]
\addplot[name path=F,blue,domain={-2*sqrt(6/5):4}] {-(1/6)*x^2+2};
\addplot[name path=G,green,domain={-2*sqrt(6/5):4}] {0.25*x^2};
\tikzfillbetween[of=F and G, split, every segment no 0/.style={pattern=north west lines, pattern color=brown!50}, every segment no 1/.style={fill=none}] {};
\end{axis}
\end{tikzpicture}
\end{document}