I could not find anything easier, so here it is!
C = randi(2,[3 3 3])-1; colorC = char(repmat('k',[3 3 3])); colorC(C == 0) = 'y'; figure(1); for x = 0 : 2 for y = 0 : 2 for z = 0 : 2 vert = [1 1 0; 0 1 0; 0 1 1; 1 1 1; 0 0 1; 1 0 1; 1 0 0; 0 0 0]; vert(:,1) = vert(:,1) + x; vert(:,2) = vert(:,2) + y; vert(:,3) = vert(:,3) + z; fac = [1 2 3 4; 4 3 5 6; 6 7 8 5; 1 2 8 7; 6 7 1 4; 2 3 5 8]; patch('Faces',fac,'Vertices',vert,'FaceColor',colorC(x + 1, y + 1, z + 1)); axis([0, 3, 0, 3, 0, 3]); alpha('color'); alphamap('rampdown'); axis equal hold on end end end
Gives you this

If you remove alpha('color'); and alphamap('rampdown'); and use axis off , you get

source share