LaTeX forum ⇒ Graphics, Figures & Tablesproblem with creating flow chart Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
cat123
Posts: 2
Joined: Thu Sep 01, 2016 9:39 pm

problem with creating flow chart

Postby cat123 » Thu Sep 01, 2016 9:59 pm

I'm trying to make a flow chart similar / the same as in that PNG image.

I tried with following but it didn't go well :cry:
Can somebody please help me or give me some advice how to begin? Thanks in advance. :)

  1. \begin{tikzpicture}[node distance=2 cm,auto,>=latex']
  2. \node [int, pin={[init]above:$\mu$}] (a) {$S$};
  3. \node (b) [left of=a,node distance=2cm, coordinate] {a};
  4. \node [int, pin={[init]above:$\mu$}] (c) [right of=a] {$I$};
  5. \node [coordinate] (end) [right of=c, node distance=2cm]{};
  6. \path[->] (b) edge node {$a$} (a);
  7. \path[->] (a) edge node {$v$} (c);
  8. \draw[->] (c) edge node {$p$} (end) ;
  9. \end{tikzpicture}
Attachments
SIRC.png
SIRC.png (3.7 KiB) Viewed 1956 times
Last edited by Stefan Kottwitz on Thu Sep 08, 2016 1:19 pm, edited 2 times in total.
Reason: code marked

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 9522
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Sep 02, 2016 12:33 am

Welcome to the forum!

If you would post a Infominimal working example, it would be much easier. The code doesn't contain the styles int and init, so it brings errors.

The drawing is not difficult, I can take a look tomorrow (here it's after midnight), perhaps post the missing styles in the meantime.

Stefan
Site admin

User avatar
Stefan Kottwitz
Site Admin
Posts: 9522
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Sep 02, 2016 1:50 pm

Here is a start. I used a loop with the fancy TikZ syntax for counting and evaluating, to not repeat commands for nodes and edges so much. :-)

  1. \documentclass[border=80pt]{standalone}
  2. \usepackage{tikz}
  3. \usetikzlibrary{arrows, positioning}
  4. \tikzset{
  5. rect/.style = { draw, minimum width = 2em, minimum height = 2ex },
  6. label/.style = { font=\scriptsize },
  7. }
  8. \begin{document}
  9. \begin{tikzpicture}[
  10. node distance = 1cm, auto, >=latex',
  11. nodes = { execute at begin node=$,
  12. execute at end node=$ },
  13. ]
  14. \coordinate (0);
  15. \foreach \txt/\label [ count=\current,
  16. evaluate = \current as \previous using int(\current-1) ]
  17. in {S/\mu,I/\beta,R/\alpha,C/\delta} {
  18. \node [rect, right = of \previous] (\current) {\txt};
  19. \draw [->] (\previous) -- node [label] {\label} (\current);
  20. \draw [->] (\current) -- node [label] {\mu} ++(0,1);
  21. }
  22. \draw [->] (4) to ++(0,-1) -| node [label, near end] {\gamma} (1);
  23. \end{tikzpicture}
  24. \end{document}


flowchart.png
flowchart.png (7.47 KiB) Viewed 1923 times


Stefan
Site admin

cat123
Posts: 2
Joined: Thu Sep 01, 2016 9:39 pm

Postby cat123 » Fri Sep 02, 2016 3:30 pm

Thank you very much :))


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests