\documentclass[final,5p,times,twocolumn]{elsarticle}
\bibliographystyle{elsarticle-num}
\usepackage{lineno,hyperref}
\modulolinenumbers[5]
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.6}
\usepackage{multirow}
\usepackage{booktabs,lipsum,makecell,amsmath}
\usepackage{subfigure}
\usepackage{lipsum}
\usepackage{color,soul}
\usepackage{lipsum}
\usetikzlibrary{arrows, positioning, shadows}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
legend pos=north west,
axis x line=middle,
axis y line=middle,
x tick label style={/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1},
y tick label style={/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1},
grid = major,
width=10cm,
height=8cm,
grid style={dashed, gray!30},
xmin=0, % start the diagram at this x-coordinate
xmax= 1, % end the diagram at this x-coordinate
ymin= 0, % start the diagram at this y-coordinate
ymax= 1, % end the diagram at this y-coordinate
%axis background/.style={fill=white},
xlabel=$s$,
ylabel=$y$,
tick align=outside,
enlargelimits=false]
% plot the stirling-formulae
\path[name path=A] (0,0) -- (1,0);
\path[name path=B] (0,1) -- (1,1);
\addplot[domain=0:1, red, ultra thick,samples=500,name path=C] {1-(1-x^3)^6};
\addlegendentry{$f(s)=(1-(1-s^4)^5$}
\addplot [green!50!black] fill between [
of=A and C,
soft clip={domain=0:0.5}];
\addplot [blue!50] fill between [
of=B and C,
soft clip={domain=0.5:1}];
\draw[thick] (0.5,1) -- (0.5,0);
\end{axis}
\path (current axis.south) node[below,anchor=north] {$t$};
\end{tikzpicture}
\end{document}
当我运行代码时我得到以下信息:
答案1
我们可以使用‘fillbetween’来实现这一点。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
legend pos=north west,
axis x line=middle,
axis y line=middle,
x tick label style={/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1},
y tick label style={/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=1},
grid = major,
width=10cm,
height=8cm,
grid style={dashed, gray!30},
xmin=0, % start the diagram at this x-coordinate
xmax= 1, % end the diagram at this x-coordinate
ymin= 0, % start the diagram at this y-coordinate
ymax= 1, % end the diagram at this y-coordinate
%axis background/.style={fill=white},
xlabel=$s$,
ylabel=$y$,
tick align=outside,
enlargelimits=false]
% plot the stirling-formulae
\path[name path=A] (0,0) -- (1,0);
\path[name path=B] (0,1) -- (1,1);
\addplot[domain=0:1, red, ultra thick,samples=500,name path=C] {1-(1-x^3)^6};
\addlegendentry{$f(s)=(1-(1-s^4)^5$}
\addplot [green!50!black] fill between [
of=A and C,
soft clip={domain=0:0.5}];
\addplot [blue!50] fill between [
of=B and C,
soft clip={domain=0.5:1}];
\draw[thick] (0.5,1) -- (0.5,0);
\end{axis}
\path (current axis.south) node[below,anchor=north] {$t$};
\end{tikzpicture}
\end{document}