![TikZ 中的因子设计图](https://linux22.com/image/240818/TikZ%20%E4%B8%AD%E7%9A%84%E5%9B%A0%E5%AD%90%E8%AE%BE%E8%AE%A1%E5%9B%BE.png)
如果有人能帮我绘制该图表我将非常感激TikZ
。
答案1
我意识到这个问题已经两年了,但我感到很无聊。以下是我对此的看法:
\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}
答案2
几点建议:
- 您可以使用 XYZ 坐标(原点位于背面的左下角),请参阅PGF 手册,第 124 页
- 使用
dashed
虚线选项,请参阅第 158 页 - 要查看彩色表面后面的线条和表面,请使用
draw opacity
选项,参见第 234 页 - 对于角落处的小圆圈,使用圆形箭头,参见第 257 页
如果出现特殊问题,请更新您的答案,然后请说明您迄今为止所做的工作。