TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The example here gives the code for drawing plane partitions with TikZ. I want to do two things at once:

  1. Label the top faces of the top cubes shown in any plane partition with a numeral that indicates the number of cubes in that stack. (The numeral should be slanted, of course.)
  2. Change the angles in the plane partition so that the viewer seems to be looking down at the plane partition "from a higher vantage point" than what the code currently yields. (The angles for the axes could be adjusted from the current 210, -30, 90 angles to, say, 220, 40, 90.) I want to do this so that I can draw stacked cubes, like plane partitions, but with the possibility that some of the "inner" (closest) cubes are higher than those cubes stacked against the walls.

Any help would be greatly appreciated. Here is a MWE (taken from the example above):

% Plane partition
% Author: Jang Soo Kim
% Three counters

% The angles of x,y,z-axes

% The top side of a cube
  \fill[fill=yellow, 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
  \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
  \fill[fill=blue, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
  shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);

% The cube 
  \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
  \foreach \a in {#1} {
    \foreach \b in \a {
      \foreach \c in {1,...,\b} {



share|improve this question
Please edit your question to include the code in it, instead of just linking to it. Self-contained questions are preferred here. – Jubobs Nov 15 '13 at 9:49
up vote 7 down vote accepted

Not sure it fits the requirements, but at the very least it's fairly easy to play with:



\begin{tikzpicture}[x=(220:1cm), y=(-40:1cm), z=(90:0.707cm)]

\foreach \m [count=\y] in {{5,3,2,2},{4,2,2,1},{2,1},{1}}{
  \foreach \n [count=\x] in \m {
  \ifnum \n>0
      \foreach \z in {1,...,\n}{
        \draw [fill=blue!30] (\x+1,\y,\z) -- (\x+1,\y+1,\z) -- (\x+1, \y+1, \z-1) -- (\x+1, \y, \z-1) -- cycle;
        \draw [fill=blue!40] (\x,\y+1,\z) -- (\x+1,\y+1,\z) -- (\x+1, \y+1, \z-1) -- (\x, \y+1, \z-1) -- cycle;
        \draw [fill=blue!10] (\x,\y,\z)   -- (\x+1,\y,\z)   -- (\x+1, \y+1, \z)   -- (\x, \y+1, \z) -- cycle;  
      \node at (\x+0.5, \y+0.5, \n) {\n};



enter image description here

share|improve this answer
That's close, but your code is putting the cubes in the wrong direction/order. Is there a way to slant the numbers so that they appear to actually be on the top faces of the top cubes? – Noob Nov 15 '13 at 19:20
You fixed one of my issues, though, so thank you! – Noob Nov 15 '13 at 19:20
@Noob to sort the direction swap the definitions of the x and y vectors. The slanting can be faked in this case by using rotate=50 in the node options. – Mark Wibrow Nov 17 '13 at 18:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.