Colouring a 3d partition away from a leg
There are ways to color a plane partition layer by layer; for instance, I have learned a lot from this post. I would like to color a partition with two colors, one color for a given leg in a corner, another color for all the other boxes.
Below is the code I am using. In the example, there is a "long" yellow leg (the x-axis), and I would like everything else to be, say, green. I can get everything on top of the yellow leg to become green, but not what's still next to the leg, namely "on the floor". I am sure this is a trivial problem but I really do not know how to modify the code.
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
cubecolors{c}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
tikz-pgf 3d
add a comment |
There are ways to color a plane partition layer by layer; for instance, I have learned a lot from this post. I would like to color a partition with two colors, one color for a given leg in a corner, another color for all the other boxes.
Below is the code I am using. In the example, there is a "long" yellow leg (the x-axis), and I would like everything else to be, say, green. I can get everything on top of the yellow leg to become green, but not what's still next to the leg, namely "on the floor". I am sure this is a trivial problem but I really do not know how to modify the code.
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
cubecolors{c}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
tikz-pgf 3d
add a comment |
There are ways to color a plane partition layer by layer; for instance, I have learned a lot from this post. I would like to color a partition with two colors, one color for a given leg in a corner, another color for all the other boxes.
Below is the code I am using. In the example, there is a "long" yellow leg (the x-axis), and I would like everything else to be, say, green. I can get everything on top of the yellow leg to become green, but not what's still next to the leg, namely "on the floor". I am sure this is a trivial problem but I really do not know how to modify the code.
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
cubecolors{c}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
tikz-pgf 3d
There are ways to color a plane partition layer by layer; for instance, I have learned a lot from this post. I would like to color a partition with two colors, one color for a given leg in a corner, another color for all the other boxes.
Below is the code I am using. In the example, there is a "long" yellow leg (the x-axis), and I would like everything else to be, say, green. I can get everything on top of the yellow leg to become green, but not what's still next to the leg, namely "on the floor". I am sure this is a trivial problem but I really do not know how to modify the code.
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
cubecolors{c}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
tikz-pgf 3d
tikz-pgf 3d
edited May 1 '17 at 18:33
Werner
437k649581648
437k649581648
asked May 1 '17 at 18:26
Andrea Ricolfi
211
211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Let me start by admitting that I have not even tried to understand the logic of your code. However, by just introducing a switch
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
which only tests if y and z are zero (you do not use negative numbers), I get

If you also have negative coordinates, use
pgfmathtruncatemacro{myc}{ifthenelse(abs(value{y})+abs(value{z})==0,1,2)}
instead.
Full code:
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f367683%2fcolouring-a-3d-partition-away-from-a-leg%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Let me start by admitting that I have not even tried to understand the logic of your code. However, by just introducing a switch
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
which only tests if y and z are zero (you do not use negative numbers), I get

If you also have negative coordinates, use
pgfmathtruncatemacro{myc}{ifthenelse(abs(value{y})+abs(value{z})==0,1,2)}
instead.
Full code:
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
add a comment |
Let me start by admitting that I have not even tried to understand the logic of your code. However, by just introducing a switch
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
which only tests if y and z are zero (you do not use negative numbers), I get

If you also have negative coordinates, use
pgfmathtruncatemacro{myc}{ifthenelse(abs(value{y})+abs(value{z})==0,1,2)}
instead.
Full code:
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
add a comment |
Let me start by admitting that I have not even tried to understand the logic of your code. However, by just introducing a switch
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
which only tests if y and z are zero (you do not use negative numbers), I get

If you also have negative coordinates, use
pgfmathtruncatemacro{myc}{ifthenelse(abs(value{y})+abs(value{z})==0,1,2)}
instead.
Full code:
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
Let me start by admitting that I have not even tried to understand the logic of your code. However, by just introducing a switch
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
which only tests if y and z are zero (you do not use negative numbers), I get

If you also have negative coordinates, use
pgfmathtruncatemacro{myc}{ifthenelse(abs(value{y})+abs(value{z})==0,1,2)}
instead.
Full code:
documentclass{article}
usepackage{xifthen}
usepackage{verbatim}
newcounter{x}
newcounter{y}
newcounter{z}
% The angles of x,y,z-axes
newcommandxaxis{210}
newcommandyaxis{-30}
newcommandzaxis{90}
% The top side of a cube
newcommandtopside[3]{
fill[fill=cubecolor, 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
newcommandleftside[3]{
fill[fill=cubecolor, 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
newcommandrightside[3]{
fill[fill=cubecolor, draw=black,shift={(xaxis:#1)},shift={(yaxis:#2)},
shift={(zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
}
% The cube
newcommandcube[3]{
topside{#1}{#2}{#3} leftside{#1}{#2}{#3} rightside{#1}{#2}{#3}
}
newcommand*cubecolors[1]{%
ifcase#1relax
orcolorlet{cubecolor}{yellow}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
orcolorlet{cubecolor}{green}%
else
colorlet{cubecolor}{blue}%
fi
}
% Definition of planepartition
% To draw the following plane partition, just write planepartition{ {a, b, c}, {d,e} }.
% a b c
% d e
newcommandplanepartition[1]{
setcounter{x}{-1}
foreach a in {#1} {
addtocounter{x}{1}
setcounter{y}{-1}
foreach b in a {
addtocounter{y}{1}
setcounter{z}{-1}
foreach c in {1,...,b} {
addtocounter{z}{1}
pgfmathtruncatemacro{myc}{ifthenelse(value{y}+value{z}==0,1,2)}
cubecolors{myc}
cube{value{x}}{value{y}}{value{z}}
}
}
}
}
usepackage{tikz}
begin{document}
begin{figure}[h]
centering
begin{tikzpicture}[scale=0.26]
planepartition{{5,4,2,1},{3,2,1},{1,1},{1,1},{1},{1},{1},{1},{1},{1}}
end{tikzpicture}
end{figure}
end{document}
answered 1 hour ago
marmot
86.9k499185
86.9k499185
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f367683%2fcolouring-a-3d-partition-away-from-a-leg%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown