How Can I draw a cube of cubes efficiently? [duplicate]

I've tried to draw a cube made by cubes on each side with TikZ. I mean a 3x3 cube with a little shift between each one. I've looked for an answer but the first hard step is starting with a good way to draw a cube. Then a need to put them on the edges of the 3x3 big cube. Basically, I just want to show three faces of our cube such that looks something like this:

But my pretty sad code to show it is this:

\documentclass{minimal}
\usepackage{tikz}
% Three counters
\newcounter{x}
\newcounter{y}
\newcounter{z}

% The angles of x,y,z-axes
\newcommand\xaxis{210}
\newcommand\yaxis{-30}
\newcommand\zaxis{90}

% The top side of a cube
\newcommand\topside[3]{
\fill[fill=red!50, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (0,1) --(150:1)--(0,0);
}

% The left side of a cube
\newcommand\leftside[3]{
\fill[fill=red, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
shift={(\zaxis:#3)}] (0,0) -- (0,-1) -- (210:1) --(150:1)--(0,0);
}

% The right side of a cube
\newcommand\rightside[3]{
\fill[fill=red!50!black, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)}, shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);}

% The cube
\newcommand\cube[3]{
\topside{#1}{#2}{#3} \leftside{#1}{#2}{#3} \rightside{#1}{#2}{#3} }

% Definition of \planepartition
% To draw the following plane partition, just write \planepartition{ {a, b,c}, {d,e} }.
%  a b c
%  d e
\newcommand\planepartition[1]{
\setcounter{x}{-1}
\foreach \a in {#1} {
\setcounter{y}{-1}
\foreach \b in \a {
\setcounter{z}{-1}
\foreach \c in {1,...,\b} {

\cube{\value{x}}{\value{y}}{\value{z}}
}
}
}
}

\begin{document}

\begin{tikzpicture}
\planepartition{{1}}

\begin{scope}[yshift=1.5cm,xshift=0cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=5cm,xshift=3cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=4cm,xshift=1.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=0cm,xshift=6cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=-1cm,xshift=4.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=1.5cm,xshift=6cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=4cm,xshift=4.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=3cm,xshift=6cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=2cm,xshift=4.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=3cm,xshift=0cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=2cm,xshift=1.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=-1cm,xshift=1.5cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=-2cm,xshift=3cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=-.5cm,xshift=3cm]
\planepartition{{1}}
\end{scope}

\begin{scope}[yshift=1cm,xshift=3cm]
\planepartition{{1}}
\end{scope}

\end{tikzpicture}

\end{document}


If you can see, I have a little trouble to align my cubes. So

• How Can I align my cubes?
• Is there an easier way to draw it?
• How can i create an efficient code to draw it?

I´m not care about another perspective of the cube or another faces.

marked as duplicate by cfr tikz-pgf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 22 '16 at 23:40

• Note that the question I've linked includes a meta-answer with links to other answers, as well as some regular answers. If nothing there works for you, then your needs must be esoteric in the extreme. In any case, best to start there and ask a follow-up question if you get stuck trying to tweak the best solution to your particular needs. Also, please don't use minimal for examples. It is not suitable. – cfr Aug 22 '16 at 23:43