I'd highly appreciate if someone could give me hand to draw this diagram in TikZ
.
2 Answers
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},
}
\def\vertexradius{.7pt}
\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);
\draw (OOO) circle (\vertexradius);
\draw (OOI) circle (\vertexradius);
\draw (OIO) circle (\vertexradius);
\draw (OII) circle (\vertexradius);
\draw (IOO) circle (\vertexradius);
\draw (IOI) circle (\vertexradius);
\draw (IIO) circle (\vertexradius);
\draw (III) circle (\vertexradius);
\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}
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
If special problems arise, please update your answer, and please then include what you've done so far.
PSTricks
orTPGF/TikZ
.