在 Tikz 中移除森林的边缘

在 Tikz 中移除森林的边缘

我使用 Tikz 在 Latex 中创建了以下森林:

\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{forest}
\usetikzlibrary{trees} % this is to allow the fork right path

\begin{figure}[H]
    \centering
    \scalebox{1.0}{
        \begin{forest}
            for tree={
            line width=0.5pt,
            draw=black,
            fit=rectangle,
            if level=0{%
                    l sep+=1cm,
                    edge from parent fork down,
                    for descendants={%
                            calign=first,
                        },
                    align=center,
                    parent anchor=south,
                }{%
                    if level=1{%
                            parent anchor=south west,
                            child anchor=north,
                            tier=three ways,
                            align=center,
                            for descendants={%
                                    child anchor=west,
                                    parent anchor=west,
                                    align=left,
                                    anchor=west,
                                    xshift=-20pt,
                                    edge path={
                                            \noexpand\path[\forestoption{edge}]
                                            (!to tier=three ways.parent anchor) |-
                                            (.child anchor)\forestoption{edge label};
                                        },
                                },
                        }{}%
                },
            }
            [Optimal Transport Application\\to Machine Learning
            [Optimal Transport \\ Usage Type
            [Optimal Transport\\Cost as Metric
            [Optimal Transport\\Mapping]]
            ]
            [Optimal Tranport\\Problem formulation
            [Wasserstein
            [Entropic Wasserstein
            [Sliced-Wasserstein
            [Gromov-Wasserstein
            [Other]]]]]
            ]
            ]
        \end{forest}}

我想要做的是删除(或涂成白色)从“最佳传输应用到机器学习”延伸下来的两条边。我该怎么做?

在此处输入图片描述

答案1

要获得无边缘,请使用no edge

\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{figure}[h]
 \centering
  \begin{forest}
      for tree={
      line width=0.5pt,
      draw=black,
      fit=rectangle,
      if level=0{%
              l sep+=1cm,
              for descendants={%
                      calign=first,
                  },
              align=center,
              parent anchor=south,
          }{%
              if level=1{%
                      no edge,% <- added
                      parent anchor=south west,
                      child anchor=north,
                      tier=three ways,
                      align=center,
                      for descendants={%
                              child anchor=west,
                              parent anchor=west,
                              align=left,
                              anchor=west,
                              xshift=-20pt,
                              edge path={
                                      \noexpand\path[\forestoption{edge}]
                                      (!to tier=three ways.parent anchor) |-
                                      (.child anchor)\forestoption{edge label};
                                  },
                          },
                  }{}%
          },
      }
      [Optimal Transport Application\\to Machine Learning
       [Optimal Transport \\ Usage Type
        [Optimal Transport\\Cost as Metric
         [Optimal Transport\\Mapping]]
       ]
       [Optimal Tranport\\Problem formulation
        [Wasserstein
         [Entropic Wasserstein
          [Sliced-Wasserstein
         [Gromov-Wasserstein
        [Other]]]]]
       ]
      ]
  \end{forest}
\end{figure}
\end{document}

在此处输入图片描述

相关内容