1

How it is possible to fill area on either side of the curve with different colors?

\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}

I expect something like this:

enter image description here

2

Like this

\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}
2
  • Thanks. It is possible to place shaded areas in background of plot? – sergiokapone Oct 3 '16 at 18:39
  • Just change to left color=blue!40 for the first \fill command – Salim Bou Oct 3 '16 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.