0

My question is with respect to the answer posted here. I'm new to learning tikz, and couldn't find what (c1.195) means in this answer? Specifically, what do the numbers after c1 signify? After some playing around, I understood that it represents the starting position of the connecting line from the parent node to child node, but I would like to change the starting position of the vertical line from the parent to the child node, and it would be helpful if I knew how to exactly adjust the starting location?

The snippet of the code where I have my doubt is given below:

    % lines from each level 1 node to every one of its "children"
\foreach \value in {1,...,4}
  \draw[->] (c1.195) |- (c1\value.west);

\foreach \value in {1,...,3}
  \draw[->] (c2.195) |- (c2\value.west);

\foreach \value in {1,...,4}
  \draw[->] (c3.195) |- (c3\value.west);
\foreach \value in {1,...,5}
  \draw[->] (c4.195) |- (c4\value.west);
  • <child>.195 is an anchor, where 195 is the angle. Angle 0 is (for standard nodes) at the east anchor, so 195 is 15 degrees below west. – user194703 Jan 13 at 22:38
2

This is to answer the question about the anchors. I do think that if you wish to draw such things, you may want to use cfr's answer instead. Anyway, in

(<node>.<alpha>)

where alpha is a number is an anchor, where the number gets interpreted as an angle. It is the point at which a ray emitted from the center of the node under the angle alpha intersects with the shape border.

enter image description here

In order to have an arguably better control you may use something like

([xshift=2ex]node.south west)

which is (for an unrotated node) 2ex right of the south west anchor of the node.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}

\tikzset{
  basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=green!30},
  level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
                   text width=8em},
  level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}

\begin{document}
\begin{tikzpicture}[
  level 1/.style={sibling distance=130mm},
  level 2/.append style={sibling distance=40mm},
  edge from parent/.style={->,draw},
  >=latex]

% root of the the initial tree, level 1
\node[root] {Fuselage}
% The first level, as children of the initial tree
  child {node[level 2] (ch1) {Requirements}
    child {node[level 2] (c1) {Costs}}
    child {node[level 2] (c2) {Structural}}
    child {node[level 2] (c3) {Low Drag}}
  }
  child {node[level 2] (ch2) {Houses}
    child {node[level 2] (c4) {Central}}
    child {node[level 2] (c5) {Protection}}
    child {node[level 2] (c5) {Shell}}
  };

% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below = of  c1, xshift=15pt] (c11) {Shell containing payload};
\node [below = of  c11] (c12) {Protection against climate};
\node [below = of  c12] (c13) {Central structural member};
\node [below = of  c13] (c14) {Houses aircraft systems};

\node [below = of  c2, xshift=15pt] (c21) {Test text a};
\node [below = of  c21] (c22) {Test text b};
\node [below = of  c22] (c23) {Test text c};

\node [below = of  c3, xshift=15pt] (c31) {Test text a};
\node [below = of  c31] (c32) {Test text b};
\node [below = of  c32] (c33) {Test text c};
\node [below = of  c33] (c34) {Test text d};

\node [below = of  c4, xshift=15pt] (c41) {Test text a};
\node [below = of  c41] (c42) {Test text b};
\node [below = of  c42] (c43) {Test text c};
\node [below = of  c43] (c44) {Test text d};
\node [below = of  c44] (c45) {Test text e};

\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \X [count=\Y] in {4,3,4,5}
{\foreach \value in {1,...,\X}
  \draw[->] ([xshift=2ex]c\Y.south west) |- (c\Y\value.west);}
\end{tikzpicture}
\end{document}

enter image description here

P.S. The code for the above illustration is

\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
 \node[draw,minimum height=1cm,minimum width=3cm] (test){};
 \draw[red] (test.195) circle[radius=2pt];
 \draw[blue] (test.center) -- ++ (195:2cm);
 \draw[dashed] (test.center) -- ++ (0:2cm);
 \draw[-stealth] (test.center) ++ (0:1cm) arc[start angle=0,end
 angle=195,radius=1cm] node[midway,above] {$\alpha$};
\end{tikzpicture}
\end{document}
| improve this answer | |

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.