How would it be possible to achieve something like the following I attach with TikZ and further to be able to color differently and even put a legend inside each smaller shape?

How would it be possible to achieve something like the following I attach with TikZ and further to be able to color differently and even put a legend inside each smaller shape?

This is an easy job for the fillbetween library from pgfplots. A simple example:

The code:
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=100,
xmax=800,
ymin=0,
ymax=600,
domain=100:800
]
% The main line (the graph of the function)
\addplot+[no marks,black,name path=main line] {0.857*x-85};
% The x axis
\addplot+[no marks,black,name path=xaxis] {0};
% The vertical lines
\draw
(axis cs:350,0) -- (axis cs:350,0.857*350-85);
\draw
(axis cs:450,0) -- (axis cs:450,0.857*450-85);
\draw
(axis cs:650,0) -- (axis cs:650,0.857*650-85);
% The horizontal lines
\draw[name path=hline1]
(axis cs:450,250) -- (axis cs:800,250);
\draw[name path=hline2]
(axis cs:650,450) -- (axis cs:800,450) coordinate (aux7);
% Filling the regions
\addplot[orange!30]
fill between[of=main line and xaxis,soft clip={domain=100:350}];
\addplot[green!80!black!50]
fill between[of=main line and xaxis,soft clip={domain=350:450}];
\addplot[magenta!50]
fill between[of=main line and hline1,soft clip={domain=450:650}];
\addplot[olive!50]
fill between[of=hline1 and xaxis,soft clip={domain=450:650}];
\addplot[cyan!50]
fill between[of=main line and hline2,soft clip={domain=650:800}];
\addplot[yellow!50]
fill between[of=hline2 and hline1,soft clip={domain=650:800}];
\addplot[red!80!black]
fill between[of=hline1 and xaxis,soft clip={domain=650:800}];
\end{axis}
\end{tikzpicture}
\end{document}
\fill operations and perhaps the intersections library from TikZ but the code will surely be longer.
– Gonzalo Medina
Jan 25 '15 at 20:56
fillbetween library, this indicates that you need to update your LaTeX system.
– Gonzalo Medina
Jan 25 '15 at 20:58
fillbetween library is not available.
– Gonzalo Medina
Jan 25 '15 at 21:06
\draw[->] (0,0) -- (8,0);(2) drawing a line goes like\draw (0,0) -- (8,8);(3) drawing a (filled) polygon goes like\draw[fill=gray] (4.5,2.5) -- (4.5,4.5) -- (6.5,6.5) -- (6.5,2.5) -- cycle;– Maarten Dhondt Jan 25 '15 at 19:34