The place where I added captions like red, blue or green I want those areas of the plan filled with the color of the captions. How do I do it.
In case you need the code for what I have done so far is here:
\documentclass{article} % say
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{changes}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\definecolor{colorforline}{RGB}{49,4,71};
\definecolor{shade}{RGB}{156, 166, 176};
\draw [very thick, color=colorforline] (-5,0) -- (5,0) node[] {};
\draw [very thick, color=colorforline] (-5,0) -- (-5,6) node[] {};
\draw [very thick,color=colorforline] plot [smooth] coordinates { (-5,0) (-3,1) (0,5) (3,1) (5,0) };
\end{tikzpicture}
\caption{Partition of sample space $S$ associated with a discrete random variable.}
\end{figure}
\end{document}



pgfplots, of course. I don't think the question can be considered a duplicate for that reason. (But it will now, presumably, get closed as one.) The issue is whether the question is a duplicate - not whether the answer might be. – cfr Dec 31 '16 at 17:25