How to modify a node in TikZ when using beamer's overlays
Here is a very simple method (inspired by my own answer to Choosing styles conditionally in TikZ).
Result
Code
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}[fragile]
\frametitle{Progressive matrix}
\tikzset{
% some styles for nodes
orange node/.style={draw,fill=orange!50,text=black},
gray node/.style={draw,fill=gray!50,text=black},
gray empty node/.style={draw,fill=gray!50,text=gray!50},
red node/.style={draw,fill=red!50,text=blue},
% styles for each overlay
my styles 1/.style={
nodes={gray empty node},
},
my styles 2/.style={
nodes={gray empty node},
column 1/.style={nodes=gray node},
},
my styles 3/.style={
nodes={orange node},
column 1/.style={nodes=gray node},
},
my styles 4/.style={
nodes={orange node},
column 1/.style={nodes=gray node},
row 2 column 2/.style={nodes=red node},
},
}
% apply overlay's styles
\only<1>{\tikzset{my styles/.style={my styles 1}}}
\only<2>{\tikzset{my styles/.style={my styles 2}}}
\only<3>{\tikzset{my styles/.style={my styles 3}}}
\only<4>{\tikzset{my styles/.style={my styles 4}}}
\centering
\begin{tikzpicture}
\matrix[matrix of nodes,
nodes={minimum width=2cm,minimum height=2cm,font=\bfseries},
column sep=-\pgflinewidth,row sep=-\pgflinewidth,my styles]{
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
};
\end{tikzpicture}
\end{frame}
\end{document}
Here's a possible solution using a comma-separated lists; the list \elist
lets you specify the entries for the matrix and the fill color for the cells; you invoke \entries
and \centries
to populate the matrix and to fill the cells, respectively:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\definecolor{myora}{RGB}{235,97,61}
\newcounter{entry}
\newcounter{tmp}
\loop\ifnum\value{entry}<9
\stepcounter{entry}
\expandafter\def\csname entry\romannumeral\value{entry}\endcsname{}
\repeat
\setcounter{entry}{0}
\loop\ifnum\value{entry}<9
\stepcounter{entry}
\expandafter\def\csname centry\romannumeral\value{entry}\endcsname{}
\repeat
\makeatletter
\def\entries{%
\setcounter{tmp}{0}
\@for\temp@a:=\elist\do
{\stepcounter{tmp}
\expandafter\edef\csname entry\romannumeral\value{tmp}\endcsname{\temp@a}
}
}
\def\centries{%
\setcounter{tmp}{0}
\@for\temp@a:=\elist\do
{\stepcounter{tmp}
\expandafter\edef\csname centry\romannumeral\value{tmp}\endcsname{\temp@a}
}
}
\makeatother
\def\elist{\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1},\noexpand\phantom{1}}\entries
\begin{document}
\begin{frame}
\only<1>{
\def\elist{gray!50,gray!50,gray!50,gray!50,gray!50,gray!50,gray!50,gray!50,gray!50}\centries
}
\only<2>{
\def\elist{3,6,9,12,15,18,21,24,27}\entries
\def\elist{gray!50,myora,myora,gray!50,myora,myora,gray!50,myora,myora}\centries
}
\only<3>{
\def\elist{2,4,6,8,10,12,14,16,18}\entries
\def\elist{myora,gray!50,myora,myora,gray!50,myora,myora,gray!50,myora}\centries
}
\only<4>{
\def\elist{-1,-2,-3,-4,-5,-6,-7,-8,-9}\entries
\def\elist{myora,myora,gray!50,myora,myora,gray!50,myora,myora,gray!50}\centries
}
\only<5>{
\def\elist{-3,-6,-9,-12,-15,-18,-21,-24,-27}\entries
\def\elist{myora,gray!50,myora,gray!50,myora,gray!50,myora,gray!50,myora}\centries
}
\only<6>{
\def\elist{1,0,1,0,1,0,1,0,1}\entries
\def\elist{gray!50,myora,gray!50,myora,gray!50,myora,gray!50,myora,gray!50}\centries
}
\centering
\begin{tikzpicture}
\matrix[matrix of nodes,every node/.style={draw,text width=2cm,align=center},ampersand replacement=\&,nodes in empty cells] (mat)
{
|[fill=\centryi]|\entryi \& |[fill=\centryii]|\entryii \& |[fill=\centryiii]|\entryiii \\
|[fill=\centryiv]|\entryiv \& |[fill=\centryv]|\entryv \& |[fill=\centryvi]|\entryvi \\
|[fill=\centryvii]|\entryvii \& |[fill=\centryviii]|\entryviii \& |[fill=\centryix]|\entryix \\
};
\node[anchor=south] at (mat.north) {Some Label};
\end{tikzpicture}\par
\end{frame}
\end{document}
An animation of the resulting document: