答案1
您可以将彩色圆圈定义为带有路径图片的节点,该节点为1/n
水平距离的某些部分着色。此样式被调用cc
并cc=1,...,5
产生彩色圆圈。着色取决于矩阵中的列索引,也可用于O1,...,O5
自动创建。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,matrix}
\begin{document}
\begin{tikzpicture}[font=\sffamily,>={Latex[round,length=3pt]},
marr/.style={semithick,->,shorten >=2pt,shorten <=1.5pt},
cc/.style={circle,draw,inner sep=1ex,
path picture={\foreach \XX in {1,...,#1}
{\path[fill=c\the\numexpr#1+1-\XX\relax] (path picture bounding box.south west) rectangle
([xshift={-2pt+2*(\pgfkeysvalueof{/pgf/inner xsep}+3pt+\pgflinewidth)/\XX}]path picture bounding box.north west);}}}]
\definecolor{c1}{RGB}{44,57,66}
\definecolor{c2}{RGB}{91,148,122}
\definecolor{c3}{RGB}{213,180,97}
\definecolor{c4}{RGB}{207,134,84}
\definecolor{c5}{RGB}{186,78,70}
\matrix[matrix of nodes,nodes in empty cells,row sep=1em,
row 1/.style={nodes={execute at begin node=O\the\pgfmatrixcurrentcolumn}},
row 2/.style={nodes={cc=\the\pgfmatrixcurrentcolumn}},
row 3/.style={nodes={text=c\the\pgfmatrixcurrentcolumn,
text width={width("What")},align=center}}] (mat)
{ & & & & \\
& & & & \\
What & time & is & it & ? \\};
\foreach \X in {1,...,5} {
\draw[marr] (mat-2-\X) -- (mat-1-\X);
\draw[marr] (mat-3-\X) -- (mat-2-\X);
\ifnum\X<5
\draw[marr] (mat-2-\X) -- (mat-2-\the\numexpr\X+1);
\fi
};
\end{tikzpicture}
\end{document}