3

I have the following figure

\begin{tikzpicture}
[ai/.style={circle,draw=none,very thick,fill=gray!50,minimum size=2.3cm,text width=2.3cm,align=center},
human/.style={circle,draw=none,very thick,fill=blue!50,minimum size=2.3cm, text width=2.3cm,align=center}, 
output/.style={circle,draw=none,very thick,fill=green!60,minimum size=2.3cm, text width=2.3cm,align=center},
accepting/.style=accepting by arrow,
node distance=4cm]
\node[ai] (ai) {AI Classifier};
\node[human] (human) [below right=of ai] {Human Annotation};
\node[output] (out) [above right=of human] {Output};
\path[->]   (ai) edge node [auto] {Not Confident} (human)
                    edge node [auto] {Confident} (out)
            (human.160) edge node [auto] {Active Learning} (ai.290)
            (human) edge [auto] node {} (out);
\end{tikzpicture}

Which results in something like this.

enter image description here

Can I avoid using the human.160 and ai.290 options and let tikz to find the right angles on its own?.

I know that in Creating double arrow / parallel arrows with tikz they provide a solution but it does not use the path option so I'm a bit confused with this.

  • Your code is not a complete MWE. Also, note that draw=none,very thick looks somewhat strange. Finally, the accepting-style is superfluous in your code. – Marian G. Jul 26 '18 at 11:59
5

Here is a solution inspired by this answer. Add the following lines to your preamble:

\newcommand\double[3][10]{%
  \draw (#2)
    edge [bend left=#1,draw=none]
    coordinate[at start](#2-#3-s)
    coordinate[at end](#2-#3-e)
    (#3)
    edge [bend right=#1,draw=none]
    coordinate[at start](#3-#2-e)
    coordinate[at end](#3-#2-s)
    (#3);
}

It is used as \double[dist]{A}{B}, where A and B are the names of the two nodes that are to be connected by a double arrow, and dist is an optional parameter controlling the distance between the two arrows (a bigger value means more distance, default value is 10). The effect of the command is that it defines four positions named A-B-s, A-B-e, B-A-s, and B-A-e. These positions can be used as the start (-s) and end (-e) positions for the arrows connecting A and B.

Here is your example, result and code.

enter image description here

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand\double[3][10]{%
  \draw (#2)
    edge [bend left=#1,draw=none]
    coordinate[at start](#2-#3-s)
    coordinate[at end](#2-#3-e)
    (#3)
    edge [bend right=#1,draw=none]
    coordinate[at start](#3-#2-e)
    coordinate[at end](#3-#2-s)
    (#3);
}
\begin{document}
\begin{tikzpicture}[%
  mynode/.style={circle,draw=none,minimum size=2.3cm,text width=2.3cm,align=center,fill=#1},
  ai/.style={mynode=gray!50},
  human/.style={mynode=blue!50}, 
  output/.style={mynode=green!60},
  node distance=4cm
]
\node[ai] (ai) {AI Classifier};
\node[human] (human) [below right=of ai] {Human Annotation};
\node[output] (out) [above right=of human] {Output};
\double{ai}{human} % <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\path[->] (ai) edge node [auto] {Confident} (out)
          (human) edge (out)
          (ai-human-s) edge node [auto] {Not Confident} (ai-human-e) % <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
          (human-ai-s) edge node [auto] {Active Learning} (human-ai-e); % <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\end{tikzpicture}
\end{document}
2

Here is an alternative to Gernot's nice answer with an double arrow (and sloped annotations).

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning,decorations.markings}
\begin{document}
\tikzset{double line with arrow/.style args={#1,#2}{decorate,decoration={markings,%
mark=at position 0 with {\coordinate (ta-base-1) at (0,3pt);
\coordinate (ta-base-2) at (0,-3pt);},
mark=at position 1 with {\draw[#1] (ta-base-1) -- (0,3pt);
\draw[#2] (ta-base-2) -- (0,-3pt);
}}}}


\begin{tikzpicture}[ai/.style={circle,draw=none,very thick,fill=gray!50,minimum size=2.3cm,text width=2.3cm,align=center},
human/.style={circle,draw=none,very thick,fill=blue!50,minimum size=2.3cm, text width=2.3cm,align=center}, 
output/.style={circle,draw=none,very thick,fill=green!60,minimum size=2.3cm, text width=2.3cm,align=center},
accepting/.style=accepting by arrow,
node distance=4cm]
\node[ai] (ai) {AI Classifier};
\node[human] (human) [below right=of ai] {Human Annotation};
\node[output] (out) [above right=of human] {Output};
\path[->]   (ai) edge node [auto] {Confident} (out)
            (human) edge[-, double line with arrow={->,<-}] 
            node [below=2pt,sloped] {Active Learning} 
            node [above=2pt,sloped] {Not Confident}(ai)
            (human) edge (out);
\end{tikzpicture}
\end{document}

enter image description here

  • nice answer (+1), however i must confess that i went lost in anti-parallel arrow definition. it probably contain an error since it generate one spurious arrow head. check code again. – Zarko Jul 26 '18 at 19:00
1

by use of tikz-cd is no need to define bidirectional arrow:

\documentclass[border=3mm]{standalone}
\usepackage{amsmath}
\usepackage{makecell}
\usepackage[svgnames]{xcolor}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[cells={nodes={circle, text width=21mm, align=center}}]
|[fill=LightGray]| \text{AI Classifier}
    \ar[rr,"\text{Confident}"]
    \ar[rd,shift left, "\text{Not Confident}"]
                            &&  |[fill=LightGreen]| \text{Output}   \\
    & |[fill=LightBlue]| \begin{tabular}{@{}c@{}}Human\\ Annotation\end{tabular}
        \ar[ul,shift left, "\text{Active Learning}"]
        \ar[ur]             &                           \\
\end{tikzcd}
\end{document}

enter image description here

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.