# Factorial-design diagrams in TikZ

I'd highly appreciate if someone could give me hand to draw this diagram in TikZ.

-
Generally, questions of the type "Can someone do this for me?" are strongly discouraged. You should make an effort to show what you've done so far to solve the problem, show the code you have so far, and specify where exactly you're stuck. As a pointer to where to start, you could take a look at tex.stackexchange.com/questions/28363/… – Jake Sep 23 '11 at 6:44
AB and BC seem odd since we cannot really distinguish where the blue and red surfaces cross. – pluton Sep 23 '11 at 13:37
You might want to have a look at Sketch - a program to generate 3D drawings using PSTricks or TPGF/TikZ. – diabonas Sep 23 '11 at 13:39
Perhaps how to draw a cube with tikz where all faces have a distinct color can help you get started. – Peter Grill Sep 23 '11 at 16:03
From the link I mentioned, you should easily be able to to A, B, and C just by choosing the colors and opacity of each plane. Enable the debug options to see where each point is and then you can produce the last three by connecting the appropriate points. To finish it off, add a line where the planes intersect as mentioned by pluton. If you make an attempt and get stuck please edit your question and we can help. – Peter Grill Sep 23 '11 at 16:54

I'm conscious this question is two years old, but I'm bored. Here is my take on this:

\documentclass{article}

\usepackage{tikz}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup[figure]{labelfont=bf}

\newcommand\drawplane[2]
{%
\draw
[
thick,
opacity=.6,
draw=#2,
fill=#2!60,
] #1 -- cycle;%
}

\newcommand\drawonecase[4]
{
\begin{tikzpicture}[scale=2]

\tikzset
{
edgevis/.style={black},
edgehid/.style={dashed,black},
}

\coordinate (OOO) at (0,0);
\coordinate (OOI) at (xyz cs:z=1);
\coordinate (OIO) at (xyz cs:y=1);
\coordinate (OII) at (xyz cs:y=1,z=1);
\coordinate (IOO) at (xyz cs:x=1);
\coordinate (IOI) at (xyz cs:x=1,z=1);
\coordinate (IIO) at (xyz cs:x=1,y=1);
\coordinate (III) at (xyz cs:x=1,y=1,z=1);

\drawplane{#1}{#2}
\drawplane{#3}{#4}

\draw[edgevis] (OOI) -- (OII) -- (OIO) -- (IIO) -- (IOO) -- (IOI) -- cycle;
\draw[edgevis] (III) -- (IIO);
\draw[edgevis] (III) -- (IOI);
\draw[edgevis] (III) -- (OII);
\draw[edgehid] (OOO) -- (OOI);
\draw[edgehid] (OOO) -- (OIO);
\draw[edgehid] (OOO) -- (IOO);

\end{tikzpicture}
}

\begin{document}
\begin{figure}
\begin{subfigure}[b]{\textwidth}
\begin{tabular}{ccc}
\drawonecase
{(OOO) -- (OOI) -- (OII) -- (OIO)}{red}
{(IOO) -- (IOI) -- (III) -- (IIO)}{blue}
&
\drawonecase
{(OOO) -- (IOO) -- (IIO) -- (OIO)}{blue}
{(OOI) -- (IOI) -- (III) -- (OII)}{red}
&
\drawonecase
{(OOO) -- (IOO) -- (IOI) -- (OOI)}{red}
{(OIO) -- (IIO) -- (III) -- (OII)}{blue}
\\
$A$ & $B$ & $C$
\end{tabular}
\caption{Main effects}
\end{subfigure}
\par
\vspace{1em}
\begin{subfigure}[b]{\textwidth}
\begin{tabular}{ccc}
\drawonecase
{(OOI) -- (OII) -- (IIO) -- (IOO)}{blue}
{(OOO) -- (OIO) -- (III) -- (IOI)}{red}
&
\drawonecase
{(OII) -- (OIO) -- (IOO) -- (IOI)}{red}
{(OOI) -- (OOO) -- (IIO) -- (III)}{blue}
&
\drawonecase
{(OOI) -- (IOI) -- (IIO) -- (OIO)}{blue}
{(OII) -- (III) -- (IOO) -- (OOO)}{red}
\\
$AB$ & $AC$ & $BC$
\end{tabular}
\caption{Two-factor interactions}
\end{subfigure}
\caption{%
Geometric presentation of contrast.
In each case, high levels are highlighted in blue, low levels in red.%
}
\end{figure}

\end{document}

-
Thanks @Jubobs for your nice answer. I solved this problem lot time ago (See here, and here but forgot to mention here. Anyway thanks for your effort and for nice answer. – MYaseen208 Oct 12 '13 at 11:11

A few pointers:

• You can use XYZ coordinates (origin would be the lower left of the back face), see PGF manual, page 124
• Use the dashed option for dashed lines, see page 158
• to see lines and surfaces behind the colored surfaces, use the draw opacity option, see page 234
• for the small circles at the corners, use circular arrow tips, see page 257