Here is another solution proposal, based on the following contributions:
With (e.g.) \tdplotsetmaincoords{\alpha}{\beta}, you can rotate your 3D-Figure so that it shows the desired perspective. This is especially useful for translucent plane partitions, since with Kim's code, the plane frames look rather confusing in that case.
However, the results are only satisfactory if one looks at the positive x-, y- and z-faces. I started implementing all other cases as well. Unfortunately, there were some unforseen challenges, which I haven't dealt with yet (shouldn't be too big of a problem, though):
If one looks, e.g., at the negative x- and y-faces and the positive z-face, one has to change the order, in which the layers are created (e.g., from front to back instead of from back to front).
The package tikz-3dplot has some problems that need to be fixed and I seem to be exploiting those. These issues occurs, if the z-axis should point down - it still points up in my example (see bottom-right figure).
% Title: Plane partition
% =============================================================================
%
% Code taken from and inspired by:
% -----------------------------------------------------------------------------
% http://www.texample.net/tikz/examples/plane-partition/
% http://www.latex-community.org/know-how/440-tikz-3dplot
% https://tex.stackexchange.com/questions/75997/shading-of-cubes-in-3d-picture
\documentclass{minimal}
\usepackage{ifthen}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.3}
\usepackage{tikz-3dplot}
% =============================================================================
% =============================================================================
% Cube side length
\newcommand\CubeLength{1.25}
% =============================================================================
% Cube side: x-value is positive
\newcommand\CubeXpos[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{x-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#1+#2}, {#3}, {#4}) -- ({#1+#2}, {#1+#3}, {#4})%
-- ({#1+#2}, {#1+#3}, {#1+#4}) -- ({#1+#2}, {#3}, {#1+#4}) -- cycle;
}
% Cube side: x-value is negative
\newcommand\CubeXneg[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{x-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#2}, {#3}, {#4}) -- ({#2}, {#1+#3}, {#4})%
-- ({#2}, {#1+#3}, {#1+#4}) -- ({#2}, {#3}, {#1+#4}) -- cycle;
}
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
% Cube side: y-value is positive
\newcommand\CubeYpos[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{y-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#1+#2}, {#1+#3}, {#4}) -- ({#2}, {#1+#3}, {#4})%
-- ({#2}, {#1+#3}, {#1+#4}) -- ({#1+#2}, {#1+#3}, {#1+#4}) -- cycle;
}
% Cube side: y-value is negative
\newcommand\CubeYneg[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{y-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#2}, {#3}, {#4}) -- ({#1+#2}, {#3}, {#4})%
-- ({#1+#2}, {#3}, {#1+#4}) -- ({#2}, {#3}, {#1+#4}) -- cycle;
}
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
% Cube side: z-value is positive
\newcommand\CubeZpos[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{z-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#2}, {#3}, {#1+#4}) -- ({#1+#2}, {#3}, {#1+#4})%
-- ({#1+#2}, {#1+#3}, {#1+#4}) -- ({#2}, {#1+#3}, {#1+#4}) -- cycle;
}
% Cube side: z-value is negative
\newcommand\CubeZneg[6]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{z-Color}{Opacity}
{%
\ifthenelse{\equal{#5}{0}}%
{%
\pgfmathsetmacro{\CubeColorPercent}%
{%
\CubeLowCGrad+%
(\CubeHiCGrad - \CubeLowCGrad)/(\CubeMaxHeight - 1)*%
(#4/#1)
}
%
\colorlet{CubeColorNew}{CubeHighColor!\CubeColorPercent!CubeLowColor}
}%
{%
\colorlet{CubeColorNew}{#5}
}
%
\colorlet{CubeColor}{CubeColorNew}
%
\fill[%
draw = black, fill = CubeColor, fill opacity = {#6}%
] ({#2}, {#3}, {#4}) -- ({#2+#1}, {#3}, {#4})%
-- ({#2+#1}, {#3+#1}, {#4}) -- ({#2}, {#3+#1}, {#4}) -- cycle;
}
% -----------------------------------------------------------------------------
% Cube
\newcommand\Cube[9]% {Length}{x-Shift}{y-Shift}{z-Shift}...%
% ...{x-Color}{y-Color}{z-Color}{Opacity}{Orientation}
{% {Length}{x-Shift}{y-Shift}{z-Shift}{Color}{Opacity}
\ifthenelse{\equal{#9}{PPP}}%
{%
\CubeXneg{#1}{#2}{#3}{#4}{white}{0}%
\CubeYneg{#1}{#2}{#3}{#4}{white}{0}%
\CubeZneg{#1}{#2}{#3}{#4}{white}{0}%
\CubeXpos{#1}{#2}{#3}{#4}{#5}{#8}%
\CubeYpos{#1}{#2}{#3}{#4}{#6}{#8}%
\CubeZpos{#1}{#2}{#3}{#4}{#7}{#8}%
}%
{}
%\ifthenelse{\equal{#9}{NPP}}%
%{%
%
%\CubeXpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZneg{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXneg{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYpos{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZpos{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
%
%\ifthenelse{\equal{#9}{PNP}}%
%{%
%
%\CubeXneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZneg{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXpos{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYneg{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZpos{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
%
%\ifthenelse{\equal{#9}{NNP}}%
%{%
%
%\CubeXpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZneg{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXneg{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYneg{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZpos{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
% .........................................................................
%\ifthenelse{\equal{#9}{PPN}}%
%{%
%
%\CubeXneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZpos{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXpos{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYpos{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZneg{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
%
%\ifthenelse{\equal{#9}{NPN}}%
%{%
%
%\CubeXpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZpos{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXneg{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYpos{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZneg{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
%
%\ifthenelse{\equal{#9}{PNN}}%
%{%
%
%\CubeXneg{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZpos{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXpos{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYneg{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZneg{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
%
%\ifthenelse{\equal{#9}{NNN}}%
%{%
%
%\CubeXpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeYpos{#1}{#2}{#3}{#4}{white}{0}%
%\CubeZpos{#1}{#2}{#3}{#4}{white}{0}%
%
%\CubeXneg{#1}{#2}{#3}{#4}{#5}{#8}%
%\CubeYneg{#1}{#2}{#3}{#4}{#6}{#8}%
%\CubeZneg{#1}{#2}{#3}{#4}{#7}{#8}%
%
%}%
%{}
}
% -----------------------------------------------------------------------------
% Three counters for shifting cubes
\newcounter{CubeCountX}
\newcounter{CubeCountY}
\newcounter{CubeCountZ}
% Set of cubes
\newcommand\CubeSet[7]% {Length}{SetCharacterization}...%
% ...{Left-Color}{Right-Color}{Top-Color}...%
% ...{Opacity}{Orientation}
{%
\setcounter{CubeCountX}{-1}
\foreach \a in {#2}%
{
\addtocounter{CubeCountX}{1}
\setcounter{CubeCountY}{-1}
\foreach \b in \a%
{
\addtocounter{CubeCountY}{1}
\setcounter{CubeCountZ}{-1}
\foreach \c in {0, ..., \b}%
{
\addtocounter{CubeCountZ}{1}
\ifthenelse{\c = 0}%
{%
\setcounter{CubeCountZ}{-1}%
}%
{% {Length}...%
%...{x-Shift}{y-Shift}{z-Shift}...%
%...{Left-Color}{Right-Color}{Top-Color}%
%...{Opacity}{Orientation}
\Cube{#1}%
{#1*\value{CubeCountX}}{#1*\value{CubeCountY}}%
{#1*\value{CubeCountZ}}%
{#3}{#4}{#5}%
{#6}{#7}%
}
}
}
}
}
% =============================================================================
% =============================================================================
\begin{document}
% -----------------------------------------------------------------------------
\noindent%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{40}{120}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
%
\draw [dotted, white] (0,0,0) -- (+\CubeLength*1.5, 0, 0);
\draw [dotted, black] (0,0,0) -- (-\CubeLength*1.5, 0, 0);
\draw [dotted, white] (0,0,0) -- (0, +\CubeLength*1.5, 0);
\draw [dotted, black] (0,0,0) -- (0, -\CubeLength*1.5, 0);
\draw [dotted, white] (0,0,0) -- (0, 0, +\CubeLength*1.5)%
node [anchor = south, yshift = +10mm, color = black] {OK};
\draw [dotted, black] (0,0,0) -- (0, 0, -\CubeLength*1.5);
%
\draw [{}-{>}] (0,0,0) -- (\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [{}-{>}] (0,0,0) -- (0, \CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [{}-{>}] (0,0,0) -- (0, 0, \CubeLength*1.33)%
node [anchor = west] {$z$};
% Draw a set of cubes
\CubeSet{\CubeLength}{{1}}{red}{blue}{green}{0.9}{PPP}
%
\end{tikzpicture}%
%
\hspace*{1mm}%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{40}{210}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
%
\draw [dotted, white] (0,0,0) -- (+\CubeLength*1.5, 0, 0);
\draw [dotted, black] (0,0,0) -- (-\CubeLength*1.5, 0, 0);
\draw [dotted, white] (0,0,0) -- (0, +\CubeLength*1.5, 0);
\draw [dotted, black] (0,0,0) -- (0, -\CubeLength*1.5, 0);
\draw [dotted, white] (0,0,0) -- (0, 0, +\CubeLength*1.5)%
node [anchor = south, yshift = +10mm, color = black] {OK};
\draw [dotted, black] (0,0,0) -- (0, 0, -\CubeLength*1.5);
%
\draw [{}-{>}] (0,0,0) -- (\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [{}-{>}] (0,0,0) -- (0, \CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [{}-{>}] (0,0,0) -- (0, 0, \CubeLength*1.33)%
node [anchor = west] {$z$};
% Draw a set of cubes
\CubeSet{\CubeLength}{{1}}{red}{blue}{green}{0.9}{PPP}
%
\end{tikzpicture}%
%
\hspace*{1mm}%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{40}{300}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
%
\draw [dotted, white] (0,0,0) -- (+\CubeLength*1.5, 0, 0);
\draw [dotted, black] (0,0,0) -- (-\CubeLength*1.5, 0, 0);
\draw [dotted, white] (0,0,0) -- (0, +\CubeLength*1.5, 0);
\draw [dotted, black] (0,0,0) -- (0, -\CubeLength*1.5, 0);
\draw [dotted, white] (0,0,0) -- (0, 0, +\CubeLength*1.5)%
node [anchor = south, yshift = +10mm, color = black] {OK};
\draw [dotted, black] (0,0,0) -- (0, 0, -\CubeLength*1.5);
%
\draw [{}-{>}] (0,0,0) -- (\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [{}-{>}] (0,0,0) -- (0, \CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [{}-{>}] (0,0,0) -- (0, 0, \CubeLength*1.33)%
node [anchor = west] {$z$};
% Draw a set of cubes
\CubeSet{\CubeLength}{{1}}{red}{blue}{green}{0.9}{PPP}
%
\end{tikzpicture}%
%
\hspace*{1mm}%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{40}{30}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
%
\draw [dotted, white] (0,0,0) -- (+\CubeLength*1.5, 0, 0);
\draw [dotted, black] (0,0,0) -- (-\CubeLength*1.5, 0, 0);
\draw [dotted, white] (0,0,0) -- (0, +\CubeLength*1.5, 0);
\draw [dotted, black] (0,0,0) -- (0, -\CubeLength*1.5, 0);
\draw [dotted, white] (0,0,0) -- (0, 0, +\CubeLength*1.5)%
node [anchor = south, yshift = +10mm, color = black] {Not OK};
\draw [dotted, black] (0,0,0) -- (0, 0, -\CubeLength*1.5);
%
\draw [{}-{>}] (0,0,0) -- (\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [{}-{>}] (0,0,0) -- (0, \CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [{}-{>}] (0,0,0) -- (0, 0, \CubeLength*1.33)%
node [anchor = west] {$z$};
% Draw a set of cubes
\CubeSet{\CubeLength}{{1}}{red}{blue}{green}{0.9}{PPP}
%
\end{tikzpicture}\\\rule{\textwidth}{0.25mm}\\
% -----------------------------------------------------------------------------
\noindent%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{70}{150}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
\draw [->] (0,0,0) -- (3*\CubeLength*1.33, 0, 0) node [anchor = west]%
{$x$};
\draw [->] (0,0,0) -- (0, 3*\CubeLength*1.33, 0) node [anchor = west]%
{$y$};
\draw [->] (0,0,0) -- (0, 0, 3*\CubeLength*1.33) node [anchor = west]%
{$z$ OK};
%
% Draw a set of cubes
\CubeSet{\CubeLength}{{3,3,3},{3,2,1},{3,1,1}}%
{red}{blue}{green}{1.0}{PPP}
%
\end{tikzpicture}%
%
\hspace*{10mm}
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{70}{330}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
\draw [->] (0,0,0) -- (3*\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [->] (0,0,0) -- (0, 3*\CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [->] (0,0,0) -- (0, 0, 3*\CubeLength*1.33)%
node [anchor = west] {$z$: Not OK};
%
% Draw a set of cubes
\CubeSet{\CubeLength}{{3,3,3},{3,2,1},{3,1,1}}%
{red}{blue}{green}{1.0}{PPP}
%
\end{tikzpicture}\\\rule{\textwidth}{0.25mm}\\
% -----------------------------------------------------------------------------
\renewcommand\CubeLength{0.75}
\pgfmathsetmacro{\CubeMaxHeight}{5} % Height of the highest tower
\pgfmathsetmacro{\CubeLowCGrad}{1} % Min. gradient from low to high (0 ... 100)
\pgfmathsetmacro{\CubeHiCGrad}{99} % Max. gradient from low to high (0 ... 100)
\colorlet{CubeLowColor}{red} % Definition of the low color
\colorlet{CubeHighColor}{blue} % Definition of the high color
%
\noindent%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{65}{120}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
\draw [->] (0,0,0) -- (4*\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [->] (0,0,0) -- (0, 4*\CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [->] (0,0,0) -- (0, 0, 5*\CubeLength*1.33)%
node [anchor = west] {$z$ OK};
%
% Draw a set of cubes
\CubeSet{\CubeLength}{{5,5,3,4},{4,4,3,3},{3,3,2,1},{1,0,2}}%
{0}{0}{0}{0.9}{PPP}
%
\end{tikzpicture}%
%
\hspace*{10mm}%
%
% Rotate the coordinate system with the help of the package 'tikz-3dplot'
\tdplotsetmaincoords{295}{300}%
%
\begin{tikzpicture}[x = 1.0cm, y = 1.0cm, z = 1.0cm, tdplot_main_coords]
%
% Draw the axes
\draw [->] (0,0,0) -- (4*\CubeLength*1.33, 0, 0)%
node [anchor = west] {$x$};
\draw [->] (0,0,0) -- (0, 4*\CubeLength*1.33, 0)%
node [anchor = west] {$y$};
\draw [->] (0,0,0) -- (0, 0, 5*\CubeLength*1.33)%
node [anchor = west] {$z$ Not OK, axis mathematically wrong};
%
% Draw a set of cubes
\CubeSet{\CubeLength}{{5,5,3,4},{4,4,3,3},{3,3,2,1},{1,0,2}}%
{0}{0}{0}{0.9}{PPP}
%
\end{tikzpicture}
% -----------------------------------------------------------------------------
\end{document}
Here's the result:
