我怎样才能画出类似的图形?

我怎样才能画出类似的图形?

我想用 Latex 绘制下图 在此处输入图片描述

我不确定最好的方法是什么,任何指点都会非常有帮助。

答案1

这是可以生成该类型图表的东西。

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,chains}

\begin{document}
\begin{tikzpicture}[node distance = 2mm and 5mm,
     box/.style = {draw, align=center,rounded corners,
        text width={width("Target variable $y$")+4pt},minimum height=3em,
        node font=\sffamily,fill=#1},
      arw/.style = {-stealth,semithick}]
 \begin{scope}[start chain=A going right,nodes={on chain,join=by arw,alias=last}]
  \node[box=gray!20] {Unobserved factors};
  \node[box=yellow!20] {Unknown mixing};
  \node[box=blue!20] {Operation $x$};
  \node[box=purple!20] {Representation $r(x)$};
  \node[box=orange!20] {Prediction $\widehat{y}$};
 \end{scope}
 \node[box=green!20,above=of A-1] (T) {Target variable $y$};
 \node[box=red!20,below=of A-1] (B) {Sensitivity variable $s$};
 \draw[arw] (T) -- (A-2);
 \draw[arw] (B) -- (A-2);
 \draw[line width=3pt,green!60!black,-{Latex[bend]},shorten <=0.5pt] (last) 
  to[bend right] node[below=2em,black,font=\Large\bfseries]{Accurate} (T);
 \draw[line width=3pt,red,-{Latex[bend]},shorten <=1.5pt,
    dash pattern=on 9pt off 6pt] (B) to[bend right] 
 node[above=2em,black,font=\Large\bfseries]{While being fair}(last);
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,chains}
\begin{document}
\begin{tikzpicture}[node distance = 2mm and 5mm,
     box/.style = {draw, align=center,rounded corners,
        text width={width("Target variable $y$")+4pt},minimum height=3em,
        node font=\sffamily,fill=#1},
      arw/.style = {-stealth,thick}]
 \begin{scope}[start chain=A going right,nodes={on chain,join=by arw,alias=last}]
  \node[box=gray!20] {Unobserved factors};
  \node[box=yellow!20] {Unknown mixing};
  \node[box=blue!20] {Operation $x$};
  \node[box=purple!20] {Representation $r(x)$};
  \node[box=orange!20] {Prediction $\widehat{y}$};
 \end{scope}
 \node[box=green!20,above=of A-1] (T) {Target variable $y$};
 \node[box=red!20,below=of A-1] (B) {Sensitivity variable $s$};
 \draw[arw] (T) -- (A-2);
 \draw[arw] (B) -- (A-2);
 \draw[line width=3pt,green!60!black,-{Latex[bend]},shorten <=0.5pt] (last.north) 
  to[out=120,in=40] node[below=2em,black,font=\Large\bfseries]{Accurate}
  (T.north);
 \draw[line width=3pt,red,-{Latex[bend]},shorten <=1.5pt,
    dash pattern=on 9pt off 6pt] (B.south) to[out=-40,in=-120] 
 node[above=2em,black,font=\Large\bfseries]{While being fair}(last.south);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容