I need to colour the area between the first and the second line of the graph in green and the area between the second and the third line of the graph in red: I am trying to do this with fillbetween, as I later I have to this with a curve. I had a look at this question, but I couldn't understand at all what soft clip does, and, quite honestly, I am a bit lost... I provide an example of what I'd want, which is a plot I coded uniquely with tikz. The second picture is where I am stuck using pgfplot.
EDIT: I kinda understood, but I still have the problem that axis are also coloured, and here I can't fill the path before drawing the functions...
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=9cm,compat=1.10}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{figure}[t]
\centering
\begin{tikzpicture}
\begin{axis}[
title = {$\delta = 0.9$},
xlabel = {$\xi$},
ylabel = {$c(\xi)$},
xmin = 0,
xmax = 1,
ymin = 0.17,
ymax= 1,
]
\addplot[
name path = A,
domain= 0:1,
samples= 100,
line width = 1.2 pt,
]
{(1+x)/2};
\node at (axis cs: .8, .84){\footnotesize$C(\xi)$};
\addplot[
name path = B,
domain= 0:1,
samples= 100,
style = dashed,
]
{(1/4 + (0.9 +x)/2};
\node at (axis cs: 0.2,0.87){\footnotesize$\bar{c}(\xi;\delta)$};
\addplot[
name path = C,
domain= 0:1,
samples= 100,
style = dashed,]
{(3/4 + (-0.9 +x)/2};
\node at (axis cs: .8, .63){\footnotesize$\underline{c}(\xi;\delta)$};
\addplot[green!20] fill between [of = A and C, soft clip={domain=0:1}];
\addplot[red!20] fill between [of = B and A, soft clip={domain=0:1}];
\end{axis}
\end{tikzpicture}
\label{fig:SustProf}
\caption{Sustainability of the ABS with a competitive fringe of retailers for fixed b.}
\end{figure}
\end{document}




soft clip={domain=0:0.6}. The value for the keydomaintakes two numbers (separated by a colon) which denote the x-value where thefill betweenarea should start and where it should end. – Jasper Habicht Nov 04 '22 at 17:21