我想用 TIKZ 重现下图。节点t_i
依赖于其相邻节点,因此在时间轴上距离越远,依赖性就越弱。
正如您在下图中看到的,我已经重现了图形的结构,但我不知道如何在箭头上建立方程。
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
main/.style={circle, minimum size = 10mm, thick, draw =black!80, node
distance = 10mm},
box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
% put nodes
\node[main,draw =red!80] (t1) {$t_i$};
\node[main] (t2) [right= of t1] {$t_{i+1}$};
\node[main] (t3) [right= of t2] {$t_{i+2}$};
\node[main] (tn) [right= of t3] {$t_{n}$};
\node[main] (t) [left= of t1] {$t_{i-1}$};
\node[main] (tt) [left= of t] {$t_{i-2}$};
\node[main] (t0) [left= of tt] {$t_{0}$};
% make path ...
\path (t3) -- node[auto=false]{\ldots} (tn);
\path (tt) -- node[auto=false]{\ldots} (t0);
% draw arrows
\draw [->] (t1) to [out=45,in=135] (tn) node [midway,below]{$P(k=0|\lambda=i)$};
\draw [->] (t1) to [out=35,in=135] (t3);
\draw [->] (t1) to (t2);
\draw [->] (t1) to (t);
\draw [->] (t1) to [out=135,in=35] (tt);
\draw [->] (t1) to [out=135,in=35] (t0);
\end{tikzpicture}
\end{document}
因此,如果您有任何建议可以让这张图形更加漂亮(结构),请不要犹豫。
谢谢
编辑1 我按照@Ignasi 的建议修改了代码,得到了以下结果:
有没有一种简单的方法可以防止方程式交叉箭头,如图所示,箭头 t_i 到 t_ {i + 1}?
\draw [->] (t1) to [out=45,in=135] node [rotate=-5,above]{\tiny
$P(k=n\mid\lambda=1)$} (tn);
\draw [->] (t1) to [out=35,in=135] node [rotate=-5,above]{\tiny
$P(k=i+1\mid\lambda=1)$}(t3) ;
编辑2t_i
根据@Ignasi的建议,我得到了以下图片。但是,我如何在和 t_ {i + 1}
(t_i
和) 之间添加等式t_{i-1}
?
修改后的代码如下:
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
main/.style={circle, minimum size = 10mm, thick, draw =black!80, node distance = 10mm},
box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
% put nodes
\node[main,draw =red!80] (t1) {$t_i$};
\node[main] (t2) [right= of t1] {$t_{i+1}$};
\node[main] (t3) [right= of t2] {$t_{i+2}$};
\node[main] (tn) [right= of t3] {$t_{n}$};
\node[main] (t) [left= of t1] {$t_{i-1}$};
\node[main] (tt) [left= of t] {$t_{i-2}$};
\node[main] (t0) [left= of tt] {$t_{0}$};
% make path ...
\path (t3) -- node[auto=false]{\ldots} (tn);
\path (tt) -- node[auto=false]{\ldots} (t0);
% draw arrows
\draw [->] (t1) to [out=45,in=135] node [midway, above] {$P(k=n|\lambda=i)$} (tn);
\draw [->] (t1) to [out=-45,in=-135] node [midway, below] {$P(k=i+2|\lambda=i)$}(t3);
\draw [->] (t1) to node[midway, below] {$P(k=i+1|\lambda=i)$} (t2);
\draw [->] (t1) to node[midway, above] {$P(k=i-1|\lambda=i)$}(t);
\draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
\draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
\end{tikzpicture}
\end{document}
答案1
可以分发链接以避免方程式重叠。
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
main/.style={circle, minimum size = 10mm, thick,
draw =black!80, node distance = 10mm},
box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
% put nodes
\node[main,draw =red!80] (t1) {$t_i$};
\node[main] (t2) [right= of t1] {$t_{i+1}$};
\node[main] (t3) [right= of t2] {$t_{i+2}$};
\node[main] (tn) [right= of t3] {$t_{n}$};
\node[main] (t) [left= of t1] {$t_{i-1}$};
\node[main] (tt) [left= of t] {$t_{i-2}$};
\node[main] (t0) [left= of tt] {$t_{0}$};
% make path ...
\path (t3) -- node[auto=false]{\ldots} (tn);
\path (tt) -- node[auto=false]{\ldots} (t0);
% draw arrows
\draw [->] (t1) to [out=45,in=135] node [midway, above]{$P(k=n|\lambda=i)$} (tn);
\draw [->] (t1) to [out=-45,in=-135] node [midway, below]{$P(k=i+2|\lambda=i)$}(t3);
\draw [->] (t1) to (t2);
\draw [->] (t1) to (t);
\draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
\draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
\end{tikzpicture}
\end{document}
编辑2的答案:
t
增加和侧状态之间的距离:
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
main/.style={circle, minimum size = 10mm, thick,
draw =black!80, node distance = 10mm},
box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
% put nodes
\node[main,draw =red!80] (t1) {$t_i$};
\node[main] (t2) [right= 3cm of t1] {$t_{i+1}$};
\node[main] (t3) [right= of t2] {$t_{i+2}$};
\node[main] (tn) [right= of t3] {$t_{n}$};
\node[main] (t) [left= 3cm of t1] {$t_{i-1}$};
\node[main] (tt) [left= of t] {$t_{i-2}$};
\node[main] (t0) [left= of tt] {$t_{0}$};
% make path ...
\path (t3) -- node[auto=false]{\ldots} (tn);
\path (tt) -- node[auto=false]{\ldots} (t0);
% draw arrows
\draw [->] (t1) to [out=45,in=135] node [midway, above]{$P(k=n|\lambda=i)$} (tn);
\draw [->] (t1) to [out=-45,in=-135] node [midway, below]{$P(k=i+2|\lambda=i)$}(t3);
\draw [->] (t1) to node [midway, above] {$P(k=i+1|\lambda=i)$}(t2);
\draw [->] (t1) to node [midway, above] {$P(k=i-1|\lambda=i)$} (t);
\draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
\draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
\end{tikzpicture}
\end{document}
答案2
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
main/.style={circle, minimum size = 10mm, thick, draw =black!80, node
distance = 10mm},
box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
% put nodes
\node[main,draw =red!80] (t1) {$t_i$};
\node[main] (t2) [right= of t1] {$t_{i+1}$};
\node[main] (t3) [right= of t2] {$t_{i+2}$};
\node[main] (tn) [right= of t3] {$t_{n}$};
\node[main] (t) [left= of t1] {$t_{i-1}$};
\node[main] (tt) [left= of t] {$t_{i-2}$};
\node[main] (t0) [left= of tt] {$t_{0}$};
% make path ...
\path (t3) -- node[auto=false]{\ldots} (tn);
\path (tt) -- node[auto=false]{\ldots} (t0);
% draw arrows
\draw [->] (t1) to [out=75,in=135] node [midway,above]{$P(k=n|\lambda=i)$} (tn);
\draw [->] (t1) to [out=35,in=135] node [midway,above]{$P(k=i + 2|\lambda=i)$} (t3);
\draw [->] (t1) to (t2);
\draw [->] (t1) to (t);
\draw [->] (t1) to [out=145,in=45] node [midway,above]{$P(k= i- 2|\lambda=i)$} (tt);
\draw [->] (t1) to [out=105,in=45] node [midway,above]{$P(k=0|\lambda=i)$} (t0);
\end{tikzpicture}
\end{document}