\documentclass{article}
\usepackage{tikz}
\newcommand\colorecases[3][yellow]{%2=col,%3=lig
\foreach \i in {#2}{%
\fill[#1] ({(\i-1)*\tmpl},{(#3-1)*\tmph}) rectangle++ (\tmpl,\tmph) ;
}
}
\begin{document}
\begin{tikzpicture}
\def\tmpl{0.3}\def\tmph{1}
\colorecases[orange]{1,...,7}{1}
\colorecases[gray]{6,7}{2}
\colorecases[teal]{6,...,10}{3}
\draw[xstep=\tmpl,ystep=\tmph] (0,0) grid ({30*\tmpl},{3*\tmph}) ;
\draw ({30*\tmpl},{0.5*3*\tmph}) node[right] {Ma légende} ;
\end{tikzpicture}
\end{document}