# Drawing a central composite design

Please I would like to draw a central composite design using PSTricks, or possibly tikz. This is the cube with the axes showed below. I have tried pst-3d but this is not easy. If you had an example of a similar figure this would be ideal.

EDIT (later): Ok I am back to home and I have found some time to do the figure with pst3d-plot. This is not the final figure but now it is easy to modify with the help of the pst3d-plot documentation (except that the options are not all documented e.g. for pstThreeDBox - do you know another doc?)

    \documentclass[12pt]{article}

\usepackage{pst-all}
\usepackage{pst-3dplot}

\begin{document}

\begin{pspicture}(-6,-6.5)(6 ,6)
\psset{Alpha=30,Beta=20}
\pstThreeDDot(6.7,0,0)
\pstThreeDDot(0,6.7,0)
\pstThreeDDot(0,0,6.7)
\pstThreeDCoor[linecolor=black, IIIDticks, IIIDlabels,
IIIDOffset={(0,0,0)},
xMin=-7.95,  yMin=-7.95,  zMin=-7.95,
xMax=8,  yMax=8,  zMax=8,
IIIDxTicksPlane=xz, IIIDxticksep = 0.4, , Dx=1,  deltax=4,
IIIDyTicksPlane=xz, IIIDyticksep = -0.4, , Dy=1,  deltay=4,
IIIDzTicksPlane=xz, IIIDzticksep = -0.4, , Dz=1,   deltaz=4]
\end{pspicture}

\end{document}


-
Can you also include your basic PSTricks experiment regardless of how basic it is? It would save others to set up an example from scratch. – percusse Oct 2 '12 at 13:26
@percusse Sorry I have just copy-paste the code in pages 9 and 10 of this documentation bakoma-tex.com/doc/generic/pst-3d/pst-3d.pdf Then I have tried to add the red lines but without success. Maybe the pst-3dplot package would be a better solution but I'm at work right now and I have to take my computer at home to install a package. – Stéphane Laurent Oct 2 '12 at 13:31

Perhaps you can use this tikz code as a starting point:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,3d}

\begin{document}

\begin{tikzpicture}[x  = {(-0.5cm,-0.5cm)},
y  = {(0.95cm,-0.25cm)},
z  = {(0cm,1cm)}]

\begin{scope}[canvas is yz plane at x=-1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle ;
\foreach \x in {-1,1}
\foreach \y in {-1,1}
\fill[blue] (\x,\y) circle (1pt);
\end{scope}
\begin{scope}[canvas is yz plane at x=1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\foreach \x in {-1,1}
\foreach \y in {-1,1}
\fill[blue] (\x,\y) circle (1pt);
\end{scope}
\begin{scope}[canvas is xz plane at y=1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\end{scope}
\begin{scope}[canvas is xz plane at y=-1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\end{scope}
\begin{scope}[canvas is yz plane at x=0]
\draw[red,dashed] (-1.5,0) -- (0,0) -- (1.5,0);
\draw[red,dashed] (0,-1.5) -- (0,0) -- (0,1.5);
\foreach \y in {-1.5,0,1.5} \fill[blue] (\y,0) circle (1pt);
\foreach \z in {-1.5,1.5} \fill[blue] (0,\z) circle (1pt);
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\draw[red,dashed] (-1.5,0) -- (0,0) -- (1.5,0);
\foreach \x in {-1.5,1.5} \fill[blue] (\x,0) circle (1pt);
\end{scope}

\end{tikzpicture}

\end{document}


There remain many things to improve but it may get you on tracks. Also, there may be an easier solution with pgfplots.

-
Thanks. I would be glad if someone could show how to add the labeled axes. I want to do this picture for tomorrow morning and right now the tikz package is not installed on my computer (I cannot install a package at the office) – Stéphane Laurent Oct 2 '12 at 13:37

Another TikZ version, using the 3D coordinate system:

## Code

\documentclass[tikz,border=2mm]{standalone}

\begin{document}

\pgfmathsetmacro{\dumbbelllength}{2}

\pgfmathsetmacro{\xangle}{10}
\pgfmathsetmacro{\yangle}{130}
\pgfmathsetmacro{\zangle}{90}

\begin{tikzpicture}
[   x={(\xangle:1cm)},
y={(\yangle:1cm)},
z={(\zangle:1cm)},
scale=2,
]

\foreach \x in {-1,1} \foreach \y in {-1,1} \foreach \z in {-1,1} \coordinate (c\x\y\z) at (\x,\y,\z);

\draw[fill=black,very thick] (0,1,0) -- (0,\dumbbelllength,0) circle (0.05cm);
\draw[fill=black,very thick] (1,0,0) -- (\dumbbelllength,0,0) circle (0.05cm);
\draw[fill=black,very thick] (0,0,-1) -- (0,0,-\dumbbelllength) circle (0.05cm);

\begin{scope}[fill opacity=0.5,draw=black,draw opacity=1,thick]
\filldraw[violet,draw=black] (c-1-1-1) -- (c-11-1) -- (c11-1) -- (c1-1-1) -- cycle;
\filldraw[red,draw=black] (c111) -- (c11-1) -- (c1-1-1) -- (c1-11) -- cycle;
\filldraw[blue,draw=black] (c111) -- (c11-1) -- (c-11-1) -- (c-111) -- cycle;

\draw[very thick] (0,0,-1) -- (0,0,1) (0,-1,0) -- (0,1,0) (-1,0,0) -- (1,0,0);

\filldraw[yellow,draw=black] (c111) -- (c1-11) -- (c-1-11) -- (c-111) -- cycle;
\filldraw[green,draw=black] (c-1-1-1) -- (c-1-11) -- (c-111) -- (c-11-1) -- cycle;
\filldraw[orange,draw=black] (c-1-1-1) -- (c-1-11) -- (c1-11) -- (c1-1-1) -- cycle;
\end{scope}

\draw[fill=black,very thick] (0,-1,0) -- (0,-\dumbbelllength,0) circle (0.05cm);
\draw[fill=black,very thick] (-1,0,0) -- (-\dumbbelllength,0,0) circle (0.05cm);
\draw[fill=black,very thick] (0,0,1) -- (0,0,\dumbbelllength) circle (0.05cm);

\draw[thick] (-2,-2,-2) -- node[below right=1cm] {\huge x} (2,-2,-2);
\draw[thick] (-2,-2,-2) -- node[below left=1cm] {\huge y} (-2,2,-2);
\draw[thick] (-2,2,-2) -- node[left=1cm] {\huge z} (-2,2,2);

\foreach \c in {-2,...,2}
{   \draw (-2,2,\c) node[inner sep=0.05cm,fill=black,circle,label=\zangle+90:\c] {};
\draw (-2,\c,-2) node[inner sep=0.05cm,fill=black,circle,label=\yangle+90:\c] {};
\draw (\c,-2,-2) node[inner sep=0.05cm,fill=black,circle,label=\xangle-90:\c] {};
}

\end{tikzpicture}

\end{document}


-