How can I fill a face of cubic with variable color on tikz?

Base on the bellow figure, I want to change color of two face. How it is possible.Both side are the same (just I cant plot correctly one of them).

\documentclass[border=10pt,tikz,multi]{standalone}
\tikzset{%
yzx/.style = {%
x={(-.385cm, -.385cm)},
y={(1cm, 0cm)},
z={(0cm, 1cm)},
},
}
\begin{document}
\begin{tikzpicture}[yzx, scale=2.5]
‎\filldraw[ fill=gray!30,looseness=1](0,0,0.2)--(2,0,0.2)--(2,2,0.2)-- (0,2,0.2)--cycle;
‎‎\filldraw[ fill=gray!30,looseness=1] (0,2,0.2)--(2,2,0.2)--(2,2,-0.2)-- (0,2,-0.2)--cycle;
‎‎\filldraw[ fill=gray!30,looseness=1] (2,0,0.2)--(2,2,0.2)--(2,2,-0.2)-- (2,0,-0.2)--cycle;
‎‎\end{tikzpicture}
\end{document}

• I don't really understand your question or why you are loading tikz-3dplot but not using it. If you can shade the one side, as shown, why isn't that in your code? And if that's not what you mean, what do you mean that you can plot? \tikzstyle is deprecated, by the way.
– cfr
Apr 20 '16 at 23:25
• You have many weird invisible characters in the code you've posted. Please check your code compiles before posting and be sure that you paste it cleanly.
– cfr
Apr 20 '16 at 23:30

This isn't probably quite what you want but an approximation. To get what you want, you probably need to read the TikZ manual discussion of shadings in the PGF layer in order to define a custom shading which will come out correctly when rotated. This will need to take account of the fact that non-rectangular shapes end up with a smaller part of the shading than rectangular ones, and that even rectangular ones only use the centre of the defined shading.

\documentclass[border=10pt,tikz,multi]{standalone}
\tikzset{%
yzx/.style = {%
x={(-.385cm, -.385cm)},
y={(1cm, 0cm)},
z={(0cm, 1cm)},
},
}
\begin{document}
\begin{tikzpicture}[yzx, scale=2.5]
‎\filldraw[fill=gray](0,0,0.2)--(2,0,0.2)--(2,2,0.2)-- (0,2,0.2)--cycle;
‎‎\filldraw[top color=blue, bottom color=red] (2,0,0.2)--(2,2,0.2)--(2,2,-0.2)-- (2,0,-0.2)--cycle;