坐标平面中一条曲线分隔的阴影区域

坐标平面中一条曲线分隔的阴影区域

如何用不同的颜色填充曲线两侧的区域?

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{figure}[h!]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
    axis lines = middle,
    clip=false,
    ylabel={$P$}, ylabel style={at=(current axis.above origin), anchor=east},
    xlabel={$T$}, xlabel style={at=(current axis.right of origin), anchor=west},
    xmin=0, xmax=1,
    ymin=0, ymax=1,
    ticks=none,
    width=10cm,
    height=10cm,
    ]
    \draw[thick, overlay] (axis cs:0.25,1) .. controls (axis cs:2,0.4) and (axis cs:-1,0.5) .. (axis cs:0.9,0)

    node[pos=0.95, above, sloped] {\footnotesize first}
    node[pos=1,above] {A}
    node[pos=0.5, above, sloped] {\footnotesize second}
    node[pos=0.75,left] {B}
    node[pos=0.05, above, sloped] {\footnotesize third}
    node[pos=0.25,right] {C}
    node[pos=0,left] {D}; 
    \node at (axis cs:0.4,0.65) {Stable};
    \node at (axis cs:0.65,0.28) {Bang};
    \end{axis}
    \end{tikzpicture}
\end{figure}

\end{document}

我期望这样的事情:

在此处输入图片描述

答案1

像这样

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{figure}[h!]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
    axis lines = middle,
    axis on top,
    ylabel={$P$}, ylabel style={at=(current axis.above origin), anchor=east},
    xlabel={$T$}, xlabel style={at=(current axis.right of origin), anchor=west},
    xmin=0, xmax=1,
    ymin=0, ymax=1,
    ticks=none,
    width=10cm,
    height=10cm,
    ]
    \fill[left color=blue!50](axis cs:0,0) rectangle (axis cs:1,1); % fill plot erea
    \fill[red!40] (axis cs:0.25,1) .. controls (axis cs:2,0.4) and (axis cs:-1,0.5) .. (axis cs:0.9,0)--(axis cs:1,0)|-cycle;% fill right side of curve 
    \draw[thick, overlay] (axis cs:0.25,1) .. controls (axis cs:2,0.4) and (axis cs:-1,0.5) .. (axis cs:0.9,0)

    node[pos=0.95, above, sloped] {\footnotesize first}
    node[pos=1,above] {A}
    node[pos=0.5, above, sloped] {\footnotesize second}
    node[pos=0.75,left] {B}
    node[pos=0.05, above, sloped] {\footnotesize third}
    node[pos=0.25,right] {C}
    node[pos=0,below left] {D}; 
    \node at (axis cs:0.4,0.65) {Stable};
    \node at (axis cs:0.65,0.28) {Bang};
    \end{axis}
    \end{tikzpicture}
\end{figure}

\end{document}

相关内容