특정 터미널 노드를 따르는 모든 노드 색상 지정

특정 터미널 노드를 따르는 모든 노드 색상 지정

나는 채워진 점으로 일부 노드를 색칠하려고 노력해 왔습니다. 하지만 포레스트 패키지 지침에 따라 첫 번째와 두 번째 행만 채울 수 있어서 막혔습니다.

내가 하려는 일:

내가 하고 싶은 것

첫 번째와 두 번째만 할 수 있었어요. 내 최소한의 코드는 다음과 같습니다.

\documentclass[border=3mm]{standalone}
\usepackage[linguistics,edges]{forest} 
\forestset{
ned/.style={%
    for tree={calign=fixed edge angles},
    delay={%
      where content={}{%
        shape=coordinate,
        for nodewalk={%
          Nodewalk={%
            on invalid=fake,
          }{%
            parent,
          }{%
            for children={anchor=north},
          }
        }{},
      }{},
    },
},
}

\begin{document}

\begin{forest}
ned
[DP
  [
    [
      [pro]
      [
        [VP
          [NP\\ t\textsubscript{1}]
          [V\\Tuttukları]
        ]
        [T]
      ]
    ]
    [C]
  ]
  [
    [NP\\aşçı]
    [D]
  ]
]
\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=red] (!1.child anchor) circle[radius=2pt];
\end{forest}

\end{document}

답변1

이해하기 쉽도록 노드당 하나의 색상을 선택했습니다(필요에 따라 빨간색으로 변경할 수 있습니다).

위에서 아래로:

\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=black] (!1.child anchor) circle[radius=2pt];
\path[fill=green] (!11.child anchor) circle[radius=2pt];
\path[fill=blue] (!112.child anchor) circle[radius=2pt];
\path[fill=yellow] (!1121.south) circle[radius=2pt];
\path[fill=orange] (!11212.child anchor) circle[radius=2pt];

여기에 이미지 설명을 입력하세요

MWE:

\documentclass[border=3mm]{standalone}
\usepackage[linguistics,edges]{forest} 
\forestset{
ned/.style={%
    for tree={calign=fixed edge angles},
    delay={%
      where content={}{%
        shape=coordinate,
        for nodewalk={%
          Nodewalk={%
            on invalid=fake,
          }{%
            parent,
          }{%
            for children={anchor=north},
          }
        }{},
      }{},
    },
},
}

\begin{document}

\begin{forest}
ned
[DP
  [
    [
      [pro]
      [
        [VP
          [NP\\ t\textsubscript{1}]
          [V\\Tuttukları]
        ]
        [T]
      ]
    ]
    [C]
  ]
  [
    [NP\\aşçı]
    [D]
  ]
]
\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=black] (!1.child anchor) circle[radius=2pt];
\path[fill=green] (!11.child anchor) circle[radius=2pt];
\path[fill=blue] (!112.child anchor) circle[radius=2pt];
\path[fill=yellow] (!1121.south) circle[radius=2pt];
\path[fill=orange] (!11212.child anchor) circle[radius=2pt];
\end{forest}

\end{document}

내 생각에는 그것이 자명하다고 생각합니다. 그렇지 않으면 알려주세요.

관련 정보