tikzpicture 中一条穿过根节点的线

tikzpicture 中一条穿过根节点的线

我遇到了一个小问题。有一条线穿过了根节点。如何修复它?

\tikzset{
        basic/.style  = {draw, text width=1.5cm, drop shadow, font=\sffamily, rectangle},
        root/.style   = {basic, rounded corners=6pt, thin, align=center,
            fill=green!60, text width=13cm},
        level 2/.style = {basic, rounded corners=4pt, thin,align=center, fill=green!60,
            text width=8em},
        level 3/.style = {basic, thin, align=left, fill=pink!60, text width=8em, align=center}
    }
    \hspace*{0cm}{
        \begin{tikzpicture}[
        level 1/.style={sibling distance=70mm},
        edge from parent/.style={->,draw},
        >=latex]

        \begin{scope}[every node/.style={level 3}]

        \node[root] (c1) {AAAAA};

        \node [below of = c1, xshift=-4cm, yshift=0cm] (c11) {S};
        \node [below of = c11] (c12) {D};
        \node [below of = c12] (c13) {R};

        \node [below of = c1, xshift=4cm, yshift=.15cm] (c14) {W};
        \node [below of = c14, yshift=-0.5cm] (c15) {K};
        \node [below of = c15, yshift=-0.5cm] (c16) {M};
        \end{scope}

        \foreach \value in {1,2,3}
        \draw[->] (c1.120) |- (c1\value.east);

        \foreach \value in {4,5,6}
        \draw[->] (c1.270) |- (c1\value.west);
        \end{tikzpicture}}

答案1

语法表示节点边界与与节点中心成 120 度角的线c1.120相交的点。在您的例子中,此点位于顶部边界上并与节点相交。如果您想遵守此语法,只需选择一个将起点置于底部边界上的角度,例如。c1\draw[->] (c1.120) |- (c1\value.east);c1.250

在此处输入图片描述

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\node[draw, minimum width=2cm, minimum height=1cm] (c1) {};

\node[draw, minimum width=2cm, minimum height=1cm, below left= 0.5cm and 0.5cm of c1] (c2) {};

\draw (c1.center) -- (120:2cm);
\draw (c1.center) -- (0:2cm);
\draw (0:1.5cm) arc [start angle=0, end angle=120, radius=1.5cm] node[midway, above right] {$120^\circ$};
\draw[fill=red] (c1.120) circle (2pt);
\draw (c1.120) |- (c2);

\begin{scope}[xshift=5cm]
\node[draw, minimum width=2cm, minimum height=1cm] (c1) {};
\node[draw, minimum width=2cm, minimum height=1cm, below left= 0.5cm and 0.5cm of c1] (c2) {};
\draw (c1.center) -- (250:2cm);
\draw (c1.center) -- (0:2cm);
\draw (0:1.5cm) arc [start angle=0, end angle=250, radius=1.5cm] node[midway, above left] {$250^\circ$};
\draw[fill=red] (c1.250) circle (2pt);
\draw (c1.250) |- (c2);
\end{scope}
\end{tikzpicture}
\end{document}

相关内容