Positioning of nodes along paths with 'above' and 'below' unclear for vertical paths
TikZ tries to intelligently interpret above
and below
. If you find this confusing, add the allow upside down
key, then below
will consistently mean the same side (the right side) of the path.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{
arrows,
scopes,
decorations.pathmorphing,
decorations.markings}
\begin{document}
\tikzset{doublepath/.style={draw, line width=2mm, shorten >=4.9mm, shorten <=4.9mm,
decoration={markings,
mark=at position 0 with {\arrow[line width=1mm, scale=-1]{triangle 45}},
mark=at position .999 with {\arrow[line width=1mm]{triangle 45}}},
postaction={decorate}},
strength/.style={midway,thin,inner sep=0,outer sep=0,sloped}}
\begin{tikzpicture}[font=\sffamily,allow upside down]
\path node[align=center] (A) {A};
\path (0,6) node[align=center] (B) {B};
\path (6,0) node[align=center] (C) {C};
\path (6,6) node[align=center] (D) {D};
\draw[doublepath,in=270-20,out=90+20] (A) to node [strength,below=2.36mm] {Label 1} (B) ;
\draw[doublepath,in=270+20,out=90-20] (A) to node [strength,below=2.36mm] {Label 2} (B) ;
\draw[doublepath,in=270-20,out=90+20] (C) to node [strength,below=2.36mm,pos=.49] {Label 1} (D) ;
\draw[doublepath,in=270+20,out=90-20] (C) to node [strength,below=2.36mm,pos=.49] {Label 2} (D) ;
\draw[doublepath,in=270+20,out=90-20] (C) to node [strength,below=2.36mm,pos=.51] {Label 3} (D) ;
\draw[doublepath,in=180-20,out=0+20] (A) to node [strength,below=2.36mm,pos=.49] {Label 4} (C) ;
\draw[doublepath,in=180-20,out=0+20] (A) to node [strength,below=2.36mm,pos=.51] {Label 5} (C) ;
\draw[doublepath,in=180+20,out=0-20] (A) to node [strength,below=2.36mm] {Label 6} (C) ;
\end{tikzpicture}
\end{document}
And with this information it is easier to avoid collisions.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{
arrows,
scopes,
decorations.pathmorphing,
decorations.markings}
\begin{document}
\tikzset{doublepath/.style={draw, line width=2mm, shorten >=4.9mm, shorten <=4.9mm,
decoration={markings,
mark=at position 0 with {\arrow[line width=1mm, scale=-1]{triangle 45}},
mark=at position .999 with {\arrow[line width=1mm]{triangle 45}}},
postaction={decorate}},
strength/.style={midway,thin,inner sep=0,outer sep=0,sloped}}
\begin{tikzpicture}[font=\sffamily,allow upside down]
\path node[align=center] (A) {A};
\path (0,6) node[align=center] (B) {B};
\path (6,0) node[align=center] (C) {C};
\path (6,6) node[align=center] (D) {D};
\draw[doublepath,in=270-20,out=90+20] (A) to node [strength,below=2.36mm] {Label 1} (B) ;
\draw[doublepath,in=270+20,out=90-20] (A) to node [strength,below=2.36mm] {Label 2} (B) ;
\draw[doublepath,in=270-20,out=90+20] (C) to node [strength,below=2.36mm,pos=.49] {Label 1} (D) ;
\draw[doublepath,in=270+20,out=90-20] (C) to node [strength,below=2.36mm,pos=.49] {Label 2} (D) ;
\draw[doublepath,in=270+20,out=90-20] (C) to node [strength,above=2.36mm,pos=.51] {Label 3} (D) ;
\draw[doublepath,in=180-20,out=0+20] (A) to node [strength,above=2.36mm,pos=.49] {Label 4} (C) ;
\draw[doublepath,in=180-20,out=0+20] (A) to node [strength,below=2.36mm,pos=.51] {Label 5} (C) ;
\draw[doublepath,in=180+20,out=0-20] (A) to node [strength,below=2.36mm] {Label 6} (C) ;
\end{tikzpicture}
\end{document}
Please note that \tikzstyle
is deprecated.
With bend left
and bend right
arrows and use of quotes
package for edge labels:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
positioning,
quotes,
}
\begin{document}
\begin{tikzpicture}[
node distance = 6cm,
every edge/.style = {draw, line width=2mm,
{Triangle[length=5mm, width=5mm]}-{Triangle[length=5mm, width=5mm]},
bend angle=20, shorten >=2mm, shorten <=2mm
},
every edge quotes/.style = {inner sep=2mm, font = \sffamily, auto=right, sloped},
]
\node (A) {A};
\node (B) [above=of A] {B};
\node (C) [right=of A] {C};
\node (D) [above=of C] {D};
%
\draw (A) edge [bend left, "Label 1"] (B)
(A) edge [bend right, "Label 2"] (B)
(A) edge [bend left, "Label 5","Label 4" '] (C)
(A) edge [bend right, "Label 6"] (C)
(C) edge [bend left, "Label 1" '] (D)
(C) edge [bend right, "Label 2","Label 3" '] (D);
\end{tikzpicture}
\end{document}
where "Label 3 '
is equivalent to "Label 3" swap
. This move Label 3 to opposite side of edge: