tikzpicture 矩阵中的颜色(实心)单个节点

tikzpicture 矩阵中的颜色(实心)单个节点

在下面的 MWE 中,我创建了一个用于我的一个类的“Coates 图”。我一直没能弄清楚的是……如何给各个节点着色?我希望它们是实心的,比如说,节点 1 -> 3 的基于 RGB 的递增灰度。这应该很容易,但我还没有找到正确的“搜索短语”。

有明显的解决方案吗?提前致谢...


\documentclass{article}

\usepackage{graphicx}
\usepackage{tikz}
 \usetikzlibrary{decorations,shapes,arrows,matrix,positioning}

\pagestyle{empty}

\begin{document}

Here is a figure:

\begin{figure}[h]
\centering
\rule[-1.75cm]{0pt}{3.95cm}
\begin{tikzpicture}[>=stealth,->,shorten >=1.5pt,transform canvas={scale=1.05}]
\matrix (a) [matrix of nodes,row sep=0.5em, column sep=5em,every node/.style={circle,draw,font=\sffamily,minimum width=1cm,thick}]
{ A & B & C \\};
\path[>=stealth,font=\small,thick] (a-1-1) edge node[below] {{\footnotesize $S^A\psi^{AB}$}} (a-1-2);
\path[>=stealth,font=\small,thick] (a-1-2) edge node[below] {{\footnotesize $S^B\psi^{BC}$}} (a-1-3);
\path[>=stealth,->,font=\small,thick] (a-1-3) edge [bend right=50] node [above] {$S_C\psi^{CA}$} (a-1-1) ;
\path[>=stealth,->,font=\small,thick] (a-1-1) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^A\bigl(1-\psi^{AB}\bigr)$}} (a-1-1) ;
\path[>=stealth,->,font=\small,thick] (a-1-2) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^B\bigl(1-\psi^{BC}\bigr)$}} (a-1-2) ;
\path[>=stealth,->,font=\small,thick] (a-1-3) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^C\bigl(1-\psi^{CA}\bigr)$}} (a-1-3) ;
\end{tikzpicture}
\end{figure}

\end{document} 

答案1

我认为有几种方法可以实现这一点。一种方法是为每个单元格添加特定样式,您可以|[<list of options>]|在单元格开头添加,例如|[fill=black!50]|

\documentclass{article}

\usepackage{graphicx}
\usepackage{tikz}
 \usetikzlibrary{decorations,shapes,arrows,matrix,positioning}

\pagestyle{empty}

\begin{document}

Here is a figure:

\begin{figure}[h]
\centering
\rule[-1.75cm]{0pt}{3.95cm}
\begin{tikzpicture}[>=stealth,->,shorten >=1.5pt,transform canvas={scale=1.05}]
\matrix (a) [matrix of nodes,row sep=0.5em, column sep=5em,every node/.style={circle,draw,font=\sffamily,minimum width=1cm,thick}]
{ |[fill=black!20]|A & |[fill=black!50]|B & |[fill=black!80]| C \\};
\path[>=stealth,font=\small,thick] (a-1-1) edge node[below] {{\footnotesize $S^A\psi^{AB}$}} (a-1-2);
\path[>=stealth,font=\small,thick] (a-1-2) edge node[below] {{\footnotesize $S^B\psi^{BC}$}} (a-1-3);
\path[>=stealth,->,font=\small,thick] (a-1-3) edge [bend right=50] node [above] {$S_C\psi^{CA}$} (a-1-1) ;
\path[>=stealth,->,font=\small,thick] (a-1-1) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^A\bigl(1-\psi^{AB}\bigr)$}} (a-1-1) ;
\path[>=stealth,->,font=\small,thick] (a-1-2) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^B\bigl(1-\psi^{BC}\bigr)$}} (a-1-2) ;
\path[>=stealth,->,font=\small,thick] (a-1-3) edge [loop, below, out=240, in=300, looseness=10, distance=0.9cm] node  {{\footnotesize $S^C\bigl(1-\psi^{CA}\bigr)$}} (a-1-3) ;
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

相关内容