带有圆圈、线条和换行符的 Tikz 链

带有圆圈、线条和换行符的 Tikz 链

我正在尝试绘制类似的东西。我试过 tikz,但无法在两点之间划线。此外,我无法获得带有年份的第一列。有什么建议吗?

在此处输入图片描述

这是我目前所拥有的

\documentclass[10pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}[->,>=stealth',auto,node distance=3cm, 
  thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

  \node[main node] (1) {};
  \node[main node] (2) [below of=1] {};
  \node[main node] (3) [below of=2] {};
  \node[main node] (4) [below of=3] {};
  \node[main node] (5) [left of=2] {};
  \node[main node] (6) [left of=3] {};
  \node[main node] (7) [left of=4] {};
  \node[main node] (8) [left of=7] {};

  \path[every node/.style={font=\sffamily\small}]
    (5) edge node [right] {} (2)
    (6) edge node [right] {} (3)
    (7) edge node [right] {} (4)
    (8) edge node [right] {} (7);
\end{tikzpicture}
\end{document}

但也许我的方向错了。

答案1

在此处输入图片描述

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{decorations.markings,
                matrix}
\usepackage{amsmath}

\begin{document}
    \begin{tikzpicture}[node distance=3cm,
  thick,
decoration = {markings,% switch on markings
              mark=% actually add a mark
              at position 0.5 with {\draw (-2pt,-2pt) -- (2pt,2pt);}
              },
                        ]
\matrix (m) [matrix of math nodes, 
             nodes in empty cells,
             column sep=9mm]
{
t-2     &   t-1     &   t       &   \text{year} \\
        &           &   \circ   &   0           \\
        &   \circ   &   \bullet &   1           \\    
        &   \bullet &   \bullet &   2           \\
\bullet &   \bullet &   \bullet &   3           \\
};
\draw[postaction={decorate}]  (m-4-2.center) -- (m-4-3.center);
\draw[postaction={decorate}]  (m-5-1.center) -- (m-5-2.center);
\draw[postaction={decorate}]  (m-5-2.center) -- (m-5-3.center);
\end{tikzpicture}
\end{document}

所有节点都组织成矩阵。对于线条使用 TikZ 库decorations.markings

相关内容