0

The code snippet is from Zarko's code from this question. I am additionally looking for labelled arrows, however the labels appear exactly on arrow, is there a way to make them outside the circle?

enter image description here


\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
               backgrounds,
               fit,
               matrix,
               positioning}
\usepackage{xcolor}

\begin{document}


\tikzset{block2/.style={rectangle, draw=gray,rounded corners, line width=.9mm,text width=26mm, fill=gray!50,text centered, 
minimum height=4em}, line/.style={draw, -latex'}}
\tikzset{level 1/.style={level distance=20mm, sibling distance=30mm},
level 2/.style={level distance=20mm, rounded corners, sibling distance=15mm},
level 3/.style={level distance=20mm, rounded corners,},
myarrow/.style=
    {draw=gray,line width=3pt,-stealth,rounded corners
    },}
\begin{tikzpicture}[
node distance = 4ex and 0em,
every edge/.style = {draw=gray,line width=3pt , -stealth,rounded corners, bend angle=20},
                    ]
    \node [block2] (1) {A};
    \node [block2, below right= of 1] (2) {B};
 
    \node [block2, below left= of 2] (3) {C};
     
    \node [block2, above left= of 3] (4) {D};
     
\path   (1.east) edge [bend left] node {some label}  (2);
\path         (2) edge [bend left] node {some more label }  (3.east);
\path         (3.west) edge [bend left] node {some even more label}  (4);
\path         (4) edge [bend left]  (1.west);       
    \end{tikzpicture}


\end{document}

2 Answers 2

2

For labels use quotes library, to its style definition add option auto:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                backgrounds,
                fit,
                matrix,
                positioning,
                quotes}

\begin{document}
\begin{tikzpicture}[
    node distance = 5ex and 0em,
     block/.style = {draw=gray, rounded corners, line width=.9mm,
                    fill=gray!30, outer sep=0pt,
                    minimum height=4em, text width=22mm, align=center},
every edge/.style = {-Stealth, draw=gray, line width=3pt, bend left=24},
every edge quotes/.style= {auto, font=\small, align=center}
                    ]
\node [block] (1) {A};
\node [block, below right= of 1] (2) {B};
\node [block, below  left= of 2] (3) {C};
\node [block, above  left= of 3] (4) {D};

\path   (1.east) edge ["some label"]  (2)
        (2)      edge ["some more label"]  (3.east)
        (3.west) edge ["some even\\ more label"]  (4)
        (4)      edge   (1.west);
\end{tikzpicture}
\end{document}

enter image description here

1
  • selected this answer for simplicity of auto
    – user0193
    Aug 23 at 19:39
2

Just add anchors to your nodes (and a small inner sep to them).

circular flow diagram

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
               backgrounds,
               fit,
               matrix,
               positioning}
\usepackage{xcolor}

\begin{document}


\tikzset{block2/.style={rectangle, draw=gray,rounded corners, line width=.9mm,text width=26mm, fill=gray!50,text centered, 
minimum height=4em}, line/.style={draw, -latex'}}
\tikzset{level 1/.style={level distance=20mm, sibling distance=30mm},
level 2/.style={level distance=20mm, rounded corners, sibling distance=15mm},
level 3/.style={level distance=20mm, rounded corners,},
myarrow/.style=
    {draw=gray,line width=3pt,-stealth,rounded corners
    },
lbl/.style={inner sep=1pt}}
\begin{tikzpicture}[
node distance = 4ex and 0em,
every edge/.style = {draw=gray,line width=3pt , -stealth,rounded corners, bend angle=20},
                    ]
    \node [block2] (1) {A};
    \node [block2, below right= of 1] (2) {B};
 
    \node [block2, below left= of 2] (3) {C};
     
    \node [block2, above left= of 3] (4) {D};
     
\path   (1.east) edge [bend left] node[lbl,above right] {some label}  (2);
\path         (2) edge [bend left] node[lbl,below right] {some more label }  (3.east);
\path         (3.west) edge [bend left] node[lbl,below left] {some even more label}  (4);
\path         (4) edge [bend left]  (1.west);       
    \end{tikzpicture}


\end{document}
1
  • 1
    upvoted for neat solution
    – user0193
    Aug 23 at 19:40

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.