1

right now I'm trying to create a flowchart in LaTeX. I'm using the Tikz package and so far I have this:

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta}

\begin{document}

\tikzstyle{block} = [rectangle, draw, fill=white, 
text width=6em, text centered, minimum height=5em]

\begin{tikzpicture}[node distance = 4cm, auto]
  \node [block] (sam) {Sample};
  \node [block, right of=sam] (var) {Variable Selection};
  \node [block, right of=var] (pro) {Data Colection/ Cleaning};
  \node [block, right of=pro] (clu) {Clustering Algorithm Selection};
  \node [block, below of=clu] (clus) {Clustering};
  \node [block, left of=clus] (val) {Cluster Validation};
  \node [block, left of=val] (res) {Result Interpretation};
  \node [block, left of=res] (kno) {Knowledge};

  \draw [->] (sam) -- (var);
  \draw [->] (var) -- (pro);
  \draw [->] (pro) -- (clu);
  \draw [->] (clu) -- (clus);
  \draw [->] (clus) -- (val);
  \draw [->] (val) -- (res); 
  \draw [->] (res) -- (kno);
\end{tikzpicture}

\end{document}

Using this code I obtain this: https://imgur.com/rZvNu5x

However, I need some arrows going in the opposite direction in between some of the blocks, namely: clu, clus, var and res. What I'm aiming is to create an adaptation of this: https://imgur.com/v00Un0L

Additionally, I would like to ask if this package allows for one of the nodes to be an image. I still haven't tried anything concerning this part, but I would like to use some of the elements of the last flow chart... Particularly the ones above data samples, knowledge and clusters. If you could indicate me where to begin I would be very grateful.

Thank you in advance!

2

an alternative, less elementary solution. employed are tikz libraries arrows.meta, chains and positioning. in nodes positioning is used syntax from the library positioning; displacement of arrows is done with transform canvas; styles definitions is moved to tikzpicture options:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, chains, positioning}

\begin{document}
    \begin{tikzpicture}[
            > = Straight Barb,
node distance = 15mm and 10mm,
  start chain = going right,
 block/.style = {rectangle, draw, fill=white,
                 text width=6em, minimum height=5em,
                 align=center},
                        ]
    \begin{scope}[every node/.style={block, on chain}]
\node (sam) {\includegraphics[width=\linewidth]{example-image}};
\node (var) {Variable Selection};
\node (pro) {Data Colection/ Cleaning};
\node (clu) {Clustering Algorithm Selection};
\node (kno) [below=of sam]  {Knowledge};
\node (res) {Result Interpretation};
\node (val) {Cluster Validation};
\node (clus) {Clustering};
    \end{scope}
\draw [->]
    (sam) edge (var)
    (var) edge (pro)
    (pro) edge (clu)
    (res)  --  (kno);
\draw [->,transform canvas={xshift=-1ex}]
    (clu) -- (clus);
\draw [->,transform canvas={xshift= 1ex}]
    (clus)  -- (clu);
\draw [->,transform canvas={yshift=1ex}]
    (clus) edge (val)
    (val)   to  (res);
\draw [->,transform canvas={yshift=-1ex}]
    (res) edge (val)
    (val)  to (clus);
    \end{tikzpicture}
\end{document}

enter image description here

4

It is rather straightforward to draw these arrows and no, you do not have to load an additional package. TikZ automatically loads the graphicx package, and for illustration purposes I replaced the content of your first node by some graphics.

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta}

\begin{document}

\tikzstyle{block} = [rectangle, draw, fill=white, 
text width=6em, text centered, minimum height=5em]

\begin{tikzpicture}[node distance = 4cm, auto]
  \node [block] (sam) {\includegraphics[width=1.5cm]{example-image-a}};
  \node [block, right of=sam] (var) {Variable Selection};
  \node [block, right of=var] (pro) {Data Colection/ Cleaning};
  \node [block, right of=pro] (clu) {Clustering Algorithm Selection};
  \node [block, below of=clu] (clus) {Clustering};
  \node [block, left of=clus] (val) {Cluster Validation};
  \node [block, left of=val] (res) {Result Interpretation};
  \node [block, left of=res] (kno) {Knowledge};

  \draw [->] (sam) -- (var);
  \draw [->] (var) -- (pro);
  \draw [->] (pro) -- (clu);
  \draw [->] (clu.-110) -- (clus.110);
  \draw [->] (clus.70) -- (clu.-70);
  \draw [->] (clus.170) -- (val.10);
  \draw [->] (val.-10) -- (clus.190);
  \draw [->] (val.170) -- (res.10); 
  \draw [->] (res.-10) -- (val.190); 
  \draw [->] (res) -- (kno);
\end{tikzpicture}
\end{document}

enter image description here

Notice that if you want the arrow distance to be universal, you could work with xshift and yshift, but I personally like the current output a bit better, yet I'll be happy to change that.

  • Thank you so much for your help. From here I can adapt the code and do exactly what I need :) – Asheliiin Apr 30 '18 at 11:18
  • @Asheliiin Glad to hear! BTW, if the solution worked for you, you may consider accepting it. – user121799 Apr 30 '18 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.