2

How do I draw this picture using Tikz?enter image description here

A MWE using Zarko's solution found here Drawing the following diagram? :


    \documentclass[12pt, a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, quotes}

\begin{document}
   \begin{figure} \centering
  \begin{tikzpicture}[
node distance = 33mm and 33mm,
     N/.style = {draw, minimum size=12mm, inner sep=0pt},
            > = {Stealth[scale=0.6]},
 every edge/.append style = {draw, ->},
every edge quotes/.append style = {font=\small\linespread{0.75}\selectfont,
                                   inner sep=5pt, sloped}
                        ]
\node [N] (A) {$S$};
\node [N, right=of A] (B) {$A$};
\node [N,below=of B] (C) {$I$};
\node [N,left=of C] (D) {$R$};
%
\draw [<-] (A) -- ++(-1,0) node[left] {$b\left(1-\nu\right)$};
\draw [<-] (D) -- ++(-1,0) node[left] {$b\nu$};
\draw [->] (A) -- ++(0,1) node[above] {$\mu S$};
\draw [->] (B) -- ++(0,1) node[above] {$\mu A$};
\draw [->] ([xshift=-3.5mm] C.south) -- ++(0,-0.4) node[below] {$\alpha I$};
\draw [->] ([xshift=+3.5mm] C.south) -- ++(0,-0.4) node[below] {$\mu I$};
\draw [->] (D) -- ++(0,-1) node[below] {$\mu R$};
\draw[->] (B)--(D) node[midway,sloped,above]{$\gamma_A$};
%
\end{tikzpicture}
\setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
\caption{Flow diagram for the SAIRS model.}
\end{figure}
    \end{document}

Feel free to improve on this MWE.

Math
  • 765
  • 1
    I don't see why I got downvoted, I provided a MWE.. – Math May 19 '22 at 10:35
  • 1
    Just a suggestion since I'm leaving for work: try the tkz-graph package. It's based on TikZ which you obviously already know, and is designed to draw exactlly that sort of figure. I discovered it a few weeks ago for a graph theory lesson and am very happy with its efficiency. – Miyase May 19 '22 at 10:51
  • 1
    I did not vote this down, but I suspect it was because on this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". If you make the Q more specific, and the example more minimal, I think you'll stand a greater chance of getting help. – Thruston May 19 '22 at 10:58
  • Not really a minimal example, though, is it … ? I removed a bunch of unrelated packages. – Ingmar May 19 '22 at 11:11
  • Rephrase the title. What's the actual problem? Why can't you draw it yourself? – MaestroGlanz May 19 '22 at 11:23
  • @MaestroGlanz The horizontal, vertical, diagonal and curved edges. – Math May 19 '22 at 11:25
  • Then this should be in your title. – MaestroGlanz May 19 '22 at 11:27
  • You can do that with the tikz-cd package. – Bernard May 19 '22 at 11:35
  • Maybe the down vote you got because of your beautiful handwriting. Helpers don't want to guess your handwriting ^^ PS: I did not downvote – Black Mild May 19 '22 at 12:13
  • @Bernard Can you do it? – Math May 19 '22 at 15:45

2 Answers2

2

Here is a solution with tikz-cd and circledsteps:

    \documentclass[pdf]{article}
    \usepackage{mathtools}
    \usepackage{tikz-cd, circledsteps}
\begin{document}

\[ \begin{tikzcd}[column sep=large, row sep=large]
 & \mu & \mu \\
\arrow[r, "b(1-\nu)"] &\Circled{S} \arrow[r, "(\beta_AA + \beta_I I)"] \arrow[u]\arrow[d, shift right=0.75ex, "\rho", swap]& \Circled{A} \arrow[u]\arrow[ld, "\delta u", swap] \arrow[d, "\nu"]\\%
\arrow[r, "b\nu"] &\Circled{R}\arrow[d]\arrow[u, shift right=0.75ex, "\epsilon", swap] & \Circled{I}\arrow[l, "\delta_I", swap]\arrow[d] \arrow[l, bend left, "\tau"]\\
& \mu & \mu + \alpha
\end{tikzcd}
\]

\end{document}

enter image description here

Bernard
  • 271,350
  • This is very nice however I want to be consistent with my document so could you reproduce this exact diagram using my MWE? – Math May 23 '22 at 10:33
0

Do you think about this plain TikZ code? Please update a more clearly hand-drawing ^^ PS: I will finish the diagram later.

enter image description here

\documentclass[12pt, a4paper]{report}
\usepackage{tikz}
\begin{document}
\begin{figure} 
\centering
\begin{tikzpicture}[>=stealth,thick]
\def\a{4}
\path[nodes={circle,draw,minimum size=12mm}]
(0,0)   node[fill=yellow] (R) {$R$}
(\a,0)  node[fill=red]    (I) {$I$}
(\a,\a) node[fill=cyan]   (A) {$A$}
(0,\a)  node[fill=green]  (S) {$S$}
;
\draw[->] (A)--(R) node[midway,sloped,above]{$\delta_a$};
\draw[->] (I)--(R) node[midway,above]{$\delta_I$};
\draw[->] (I.-135) to[bend left] node[midway,below]{$\tau$} (R.-45);
\draw[->] (S)--+(0,1.5) node[above]{$\mu$};
\draw[<-] (S)--+(-2,0) node[above]{$b(1-\mu)$};
\end{tikzpicture}
\caption{Flow diagram for the SAIRS model.}
\end{figure}
\end{document}
Black Mild
  • 17,569
  • The writing is not important aha! though I do like your humour, it made me smile :) I just need the arrows in place! – Math May 19 '22 at 12:42