0

I want to make the attached tikzpicture. First, how do I change the arrows to ankled arrows? Second, how do I align a node below a node that's at the top to skip the one between them?

enter image description here

enter image description here

Code

\begin{tikzpicture}
\node [io] (a){technical device};
\node [below=of a] (does) {Does it move?};
\node [below right= of does] (si) {Should it?}; 
\node [below left = of does] (si2) {Should it?};
\node [below left = of si2] (wd40) {WD-40};
\node [below right = of si2] (ok) {OK};
\node [below right= of si] (dt) {duct tape};

\draw[->]
    (a) edge (does)
    (does) -- ++(2.9,0)
         |- (si.north)
    (does) edge (si2)
    (si2) edge (wd40)
    (si2) edge (ok);

\end{tikzpicture}

edit2:


\draw[->]
    (a) edge (does)
    (does) -- ++(2.9,0)
         -| (si.north)
    (does) edge (si2)
    (si2) -- ++(-1.5,0)
         -| (wd40.north)
    (si2) -- ++(1.5,0)
         -| (ok.north)
    (si) -- ++(2,0)
         -|(dt.north);

Now these paths are just lines why that?

  • If you add the code that produces the image you can produce, it will be easy. In forest you need to use forked edges, in TikZ you can change the to path or do other things. – Schrödinger's cat Nov 11 '19 at 18:53
1

If you really want to use tikz and not forest to draw this decision tree, you could use

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[%
  decision/.style={diamond,draw, text width=4.5em, text badly centered,
    inner sep=1pt},
  io/.style={trapezium, trapezium left angle=70, trapezium right angle=110,
    minimum width=3cm, minimum height=1cm, text centered, 
    draw=black,trapezium stretches=true},
  block/.style={minimum width=2cm,draw},
  forked/.style={to path={-| (\tikztotarget) \tikztonodes}},
  node distance=1cm and 2cm
    ]
\node [io] (a){technical device};
\node [below=of a,decision] (does) {Does it move?};
\node [below right= of does,decision] (si) {Should it?}; 
\node [below left = of does,decision] (si2) {Should it?};
\node [below left=1cm and 1cm of si2,block] (wd40) {WD-40};
\node [below right=1cm and 1cm of si,block] (dt) {duct tape};
\path (wd40) -- node [block] (ok) {OK} (dt);

\draw[-stealth,semithick]    (a) edge (does);
\draw[-stealth,semithick,forked,nodes={above,font=\sffamily}]
    (does) edge node {yes}(si.north)
    (does) edge  node {no} (si2)
    (si2) edge node {yes}  (wd40)
    (si2) edge node {no}  (ok.160)
    (si) edge node {yes}  (ok.20)
    (si) edge node {no}  (dt);
\end{tikzpicture}
\end{document}

enter image description here

I added a preamble and some styles. BTW, in case you get told that things become so much better with the quotes library: please take these statements with a grain of salt.

|improve this answer|||||
  • Well thanks mate. So node.("number") starts always on the top? – Rack Cloud Nov 11 '19 at 19:33
  • @RackCloud No. These are angles. Roughly speaking, these are the positions where a ray emitted from the node centers under an angle <angle> hits the node boundary. – Schrödinger's cat Nov 11 '19 at 19:39

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.