我有这张照片:
它是使用此代码生成的:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.14, label style={font=\huge}, tick label style={font=\huge}}
\usepgfplotslibrary{fillbetween}
\begin{document}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\begin{tikzpicture}
\begin{axis}[
no markers, domain=-4:4, samples=100,
axis x line=bottom, axis y line=left,
every axis y label/.style={at=(current axis.above origin),anchor=south},
every axis x label/.style={at=(current axis.right of origin),anchor=west},
height=5cm, width=16cm,
xtick={-3, -2, -1, 0, 1, 2, 3}, ytick=\empty,
enlargelimits=false, clip=false, axis on top,
xticklabels={-3, -2, -1, 0, 1, 2, 3}, % so do it manually instead
]
\addplot [very thick,black, name path=f] {gauss(0,1)};
\path[name path=axis](axis cs:-2,0) -- (axis cs:-1,0);
\addplot[thick, color=blue, fill=blue, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=-2:-1},];
\path[name path=axis](axis cs:1,0) -- (axis cs:2,0);
\addplot[thick, color=blue, fill=blue, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=1:2},];
\path[name path=axis](axis cs:-3,0) -- (axis cs:-2,0);
\addplot[thick, color=yellow, fill=yellow, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=-3:-2},];
\path[name path=axis](axis cs:2,0) -- (axis cs:3,0);
\addplot[thick, color=yellow, fill=yellow, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=2:3},];
\path[name path=axis](axis cs:-1,0) -- (axis cs:1,0);
\addplot[thick, color=red, fill=red, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=-1:1},];
\end{axis}
\end{tikzpicture}
\end{document}
我想去掉那个白色三角形。也就是说,从 -1 到 1 的区域应该全部是红色。
我如何获得它?
作为备份,如果这不起作用,在 (-1, 1) 处进行红色处理并在 (-2, 2) 处进行红色与蓝色重叠以及在 (-3, 3) 处进行红色和蓝色与黄色重叠也有效(甚至可能更好...)