如何在交换图中对单元格进行着色

如何在交换图中对单元格进行着色

我想在 tikz 中绘制以下类型的图表: 目标渲染

我目前的解决方案是:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}
\pgfplotsset{compat=1.14}
\newcommand{\mstate}{(s,s,s)}

\begin{document}

\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}

\definecolor{pamblue}{rgb}{.78, .90, .98}

\begin{tikzpicture}[scale=2]
  \tikzset{
    vertex/.style={text centered, fill, color=black, circle, inner sep=.7pt},
    state/.style={},
    every label/.style={label distance=-2pt}
  }

  \node[vertex, draw] (a) at (-1,0) [label=left:$\mstate_1$] {};
  \node[vertex, draw] (d) at (1,0) [label=right:$\mstate_3$] {};
  \node[vertex, draw] (b) at (0,1) [label=above:$\mstate_2'$] {};
  \node[vertex, draw] (c) at (0,-1) [label=below:$\mstate_2$] {};

  \begin{pgfonlayer}{bg}
    \fill[pamblue] (a.center) to [bend left] (b.center)
                   to [bend left] (d.center)
                   to [bend left] (c.center)
                   to [bend left] (a.center);
  \end{pgfonlayer}
  \begin{scope}[thick,decoration={
       markings,
       mark=at position 0.5 with {\arrow{>}}}
     ] 
     \draw[postaction={decorate}] (a.center) to [bend left] (b.center);
     \draw[postaction={decorate}] (b.center) to [bend left] (d.center);
     \draw[postaction={decorate}] (a.center) to [bend right] (c.center);
     \draw[postaction={decorate}] (c.center) to [bend right] (d.center);
   \end{scope}
\end{tikzpicture}
\end{document}

但是我想在我的文档中多次使用这种图表...有没有办法先画出箭头,然后再使用它们来定义阴影区域?

相关内容