2

I have the following tickz flow-chart but I want the arrow that goes from the "compute color features" node to stop at the right-hand corner of the "SVM and RF models" node. How do I do this?

enter image description here

Here is my code.

\documentclass{article}
\usepackage{tikz}


\begin{figure}[! h]
\begin{center}
\begin{tikzpicture}

\tikzstyle{block1} = [rectangle, draw,fill=gray!20, 
    text width=3cm, text centered, rounded corners, minimum height=1cm]
\tikzstyle{block2} = [rectangle, draw,fill=gray!20, 
    text width = 2cm, text centered, rounded corners, minimum height = 2cm]

  
   \node[block1](Input){Input images};
   
  
   \node[block2, below of = Input , xshift = -2cm , yshift = -2cm](glcm){Compute GLCM matrix};
   
   \node[block2, below of = Input , xshift = 2cm , yshift = -2cm](col_features){Compute colour features};
   
  \node[block1, below of = glcm , yshift = -1cm](ext_features){Calculate extracted features};
   
   
   \node[block1, below of = ext_features , yshift = -1cm](average_feature){Calculate average of features};
   
  
  \node[block1, below of = average_feature , yshift = -1cm](models){SVM and RF models};
    
   \node[block2, below of = models , xshift = -2cm , yshift = -2cm](tumor){Image contains a tumor};
   
   \node[block2, below of = models , xshift = 2cm , yshift = -2cm](no_tumor){Image does not contain tumor};

 

    \draw[->](Input)--(glcm);
    \draw[->](glcm)--(ext_features);
    \draw[->](ext_features)--(average_feature);
    \draw[->](average_feature)--(models);
    \draw[->](models)--(tumor);
    \draw[->](models)--(no_tumor);
    \draw[->](Input)--(col_features);
    \draw[->](col_features)--(models);

\end{tikzpicture}
\end{center}
\caption{Feature extraction flow chart}
\label{fig:feat_ext}
\end{figure}
\end{document}```
4
  • Welcome to TeX.SE!
    – Mensch
    Oct 30, 2021 at 20:23
  • Thank you! Very excited to join the community. Oct 30, 2021 at 20:24
  • Please help the community of this site help you and always provide a compilable snippet of code that starts with \documentclass{...} and ends with \end{document}. Oct 30, 2021 at 20:33
  • 1
    Thanks for the tip see my edit. @JasperHabicht. Oct 30, 2021 at 20:37

2 Answers 2

3

Welcome to TeX.SX! You can use an anchor. TikZ provides a bunch of such anchors for the default node shapes that you can reference to by adding the anchor name to the node name (connected by a dot/fullstop). Most node shapes provide the anchors north, south, east and west and combinations thereof, such as north east, which would be the anchor you could use here.

See chapter 71 of the TikZ/PGF manual where the shapes library is discussed which anchors are available for the predefined node shapes.

\documentclass[tikz, border=1mm]{standalone}

\begin{document}
\begin{tikzpicture}

    \tikzstyle{block1} = [rectangle, draw,fill=gray!20, 
    text width=3cm, text centered, rounded corners, minimum height=1cm]
    \tikzstyle{block2} = [rectangle, draw,fill=gray!20, 
    text width = 2cm, text centered, rounded corners, minimum height = 2cm]
    
    \node[block1](Input){Input images};
    \node[block2, below of = Input, xshift = -2cm, yshift = -2cm](glcm){Compute GLCM matrix};
    \node[block2, below of = Input, xshift = 2cm, yshift = -2cm](col_features){Compute colour features};
    \node[block1, below of = glcm, yshift = -1cm](ext_features){Calculate extracted features};
    \node[block1, below of = ext_features, yshift = -1cm](average_feature){Calculate average of features};
    \node[block1, below of = average_feature, yshift = -1cm](models){SVM and RF models};
    \node[block2, below of = models, xshift = -2cm, yshift = -2cm](tumor){Image contains a tumor};
    \node[block2, below of = models, xshift = 2cm, yshift = -2cm](no_tumor){Image does not contain tumor};

    \draw[->](Input)--(glcm);
    \draw[->](glcm)--(ext_features);
    \draw[->](ext_features)--(average_feature);
    \draw[->](average_feature)--(models);
    \draw[->](models)--(tumor);
    \draw[->](models)--(no_tumor);
    \draw[->](Input)--(col_features);
    \draw[->](col_features)--(models.north east);

\end{tikzpicture}
\end{document}

enter image description here

5

I wouldn't use \tikzstyle nor below of but below=of from the positioning library. However, for such tree diagrams there is an even more powerful option: forest, so you do not even have to worry about such things. Also, a bent arrow may look better in this case.

\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
 for tree={rectangle, draw,fill=gray!20, 
    text width=3cm,text centered, rounded corners, minimum height=1cm,
    edge={->}}
   [Input images
    [Compute\\ GLCM\\ matrix
     [Calculate extracted features
      [Calculate average of features
       [SVM and RF models,alias=BR
        [Image\\ contains\\ a tumor]
        [Image\\ does not\\ contain tumor]
       ]    
      ] 
     ]  
    ] 
   [Compute\\ colour\\ features,alias=TR]
  ] 
 \draw[->] (TR) to[out=-90,in=45] (BR.north east); 
\end{forest}  
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .