1

I'm trying to draw a Markov chain transition diagram showing a success run like such: enter image description here

However, my own attempt looks rather ugly compared the the picture above:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document} \begin{tikzpicture} [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% node distance =.8cm, place/.style={rectangle,draw=blue!50,fill=blue!20,thick, inner sep=0pt,minimum size=6mm} ]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \node[place] (1) {$0$}; \node[place] (2) [right=of 1] {$1$}; \node[place] (3) [right=of 2] {$2$}; \node[place] (4) [right=of 3] {$3$}; \node[text] (5) [right=of 4] {$\cdots\cdots$}; \node[place] (6) [right=of 5] {$2021$}; \node[text] (7) [right=of 6] {$\cdots$};

\draw [->,thick] (1.south west) to [bend left=55] node[left] {1} (1.north west); \draw [->,thick] (1.north east) to [bend left=15] node[above] {$P_0$} (2.north west); \draw [->,thick] (2.north east) to [bend left=15] node[above] {$P_1$} (3.north west); \draw [->,thick] (3.north east) to [bend left=15] node[above] {$P_2$} (4.north west); \draw [->,thick] (4.north east) to [bend left=15] node[above] {$P_3$} (5.north west); \draw [->,thick] (5.north east) to [bend left=15] node[above] {$P_{2020}$} (6.north west); \draw [->,thick] (6.north east) to [bend left=15] node[above] {$P_{2021}$} (7.north west); \draw [<-,thick] (1.south east) to [bend right=15] node[below] {$1-P_3$} (4.south west); \draw [<-,thick] (1.south east) to [bend right=15] node[below] {$1-P_2$} (3.south west);

\end{tikzpicture} \end{document}

enter image description here

with overlapping arrows and such. Any suggestions on replicating the first diagram?

jeb2
  • 137

1 Answers1

2

enter image description here

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{positioning}  %                 ...positioning nodes
\usetikzlibrary{arrows}       %                 ...customizing arrows
\tikzset{node distance=1cm, % Minimum distance between two nodes. Change if necessary.
         every state/.style={ % Sets the properties for each state
           semithick,draw=blue!50,
           fill=blue!20},
         initial text={},     % No label on start arrow
         double distance=4pt, % Adjust appearance of accept states
         every edge/.style={  % Sets the properties for each transition
         draw, ->,>=stealth',     % Makes edges directed with bold arrowheads
           auto, thick},
}
\begin{document}
\begin{tikzpicture}

\node[state] (1) {$0$}; \node[state] (2) [right=of 1] {$1$}; \node[state] (3) [right=of 2] {$2$}; \node[state] (4) [right=of 3] {$3$}; \node[] (5) [right=of 4] {$\cdots\cdots$}; \node[state] (6) [right=of 5] {$2021$}; \node[] (7) [right=of 6] {$\cdots$};

\path (1) edge[loop left] node{$1-p_0$} (1); % \draw [->,thick] (1.south west) to [bend left=55] node[left] {1} (1.north west); \draw [->,thick] (1.north east) to [bend left=55] node[above] {$P_0$} (2.north west); \draw [->,thick] (2.north east) to [bend left=55] node[above] {$P_1$} (3.north west); \draw [->,thick] (3.north east) to [bend left=55] node[above] {$P_2$} (4.north west); \draw [->,thick] (4.north east) to [bend left=55] node[above] {$P_3$} (5.north west); \draw [->,thick] (5.north east) to [bend left=55] node[above] {$P_{2020}$} (6.north west); \draw [->,thick] (6.north east) to [bend left=55] node[above] {$P_{2021}$} (7.north west); \draw [<-,thick] (1.south east) to [bend right=55] node[pos=0.5, below] {$1-P_3$} (4.south west); \draw [<-,thick] (1.south east) to [bend right=55] node[pos=0.8, below=4pt] {$1-P_2$} (3.south west);

\end{tikzpicture} \end{document}

js bibra
  • 21,280