TikZ:路径创建多余的箭头

TikZ:路径创建多余的箭头

以下 LaTeX 代码创建了一个冗余的不需要的测量块中的箭头。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
    \begin{tikzpicture}[>=latex']
        \tikzset{block/.style= {draw,rectangle,align=center,minimum width=2cm,minimum height=1cm}}
        \node [block]     (measures)  {Measures};

        \node [block, above right =2cm of measures](accuracy)   {Accuracy};
        \node [block, below =0.5cm of accuracy]       (precision)     {Precision};
        \node [block, below =0.5cm of precision]      (recall)        {Recall};
        \node [block, below =0.5cm of recall]         (fmeasure)      {Fmeasure};

        \path[draw,->] 
            (measures.east) edge (accuracy.west)
            (measures.east) edge (precision.west)
            (measures.east) edge (recall.west)
            (measures.east) edge (fmeasure.west)
        ;
    \end{tikzpicture}
\end{document}

代码生成如下图像。

多余的箭头

有办法摆脱它吗?

答案1

edge是一头野兽,所以你应该小心驾驶。在not->选项中使用:edge\draw

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
    \begin{tikzpicture}[>=latex']
        \tikzset{block/.style= {draw,rectangle,align=center,minimum width=2cm,minimum height=1cm}}
        \node [block]     (measures)  {Measures};

        \node [block, above right =2cm of measures](accuracy)   {Accuracy};
        \node [block, below =0.5cm of accuracy]       (precision)     {Precision};
        \node [block, below =0.5cm of precision]      (recall)        {Recall};
        \node [block, below =0.5cm of recall]         (fmeasure)      {Fmeasure};

        \path[draw]
            (measures.east) edge[->] (accuracy.west)
            (measures.east) edge[->] (precision.west)
            (measures.east) edge[->] (recall.west)
            (measures.east) edge[->] (fmeasure.west)
        ;
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

forest自动限制选项的解决方案edge

\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
  \begin{forest}
    for tree={
      grow'=0,
      parent anchor=east,
      child anchor=west,
      draw,
      minimum width=20mm,
      minimum height=10mm,
      edge={-{Latex}},
      l sep+=10mm,
    }
    [Measures
      [Accuracy]
      [Precision]
      [Recall]
      [F measure]
    ]
  \end{forest}
\end{document}

平原树

相关内容