Tikz 树 - 线特征

Tikz 树 - 线特征

在我的 MWE 中:

  • 为什么line width=0pt不起作用?
  • 为什么某一级别的虚线论点会在下一级别的虚线论点上出现?

在此处输入图片描述

\documentclass[tikz]{standalone}
\usetikzlibrary{trees}

\begin{document}

\begin{tikzpicture}[level distance=5mm,
    level 1/.style={sibling distance=32mm,line width=0pt},
    level 2/.style={sibling distance=16mm,dashed},
    level 3/.style={sibling distance=8mm,level distance=12mm},
    %level 4/.style={sibling distance=7mm},
    %every fit/.style={rectangle,draw,inner sep=3.5pt},
    grow=right]

\scriptsize
\node {$\bullet$}
child {node {P}
        child {node{PP}
            child {node{PPP}}
            child {node{PPF}}
        }
        child {node{PF}
            child {node{PFP}}
            child {node{PFF}}
        }
    }
child {node {F}
        child {node{FP}
            child {node{FPP}}
            child {node{FPF}}
        }
        child {node{FF}
            child {node{FFP}}
            child {node{FFF}}
        }
    } ;
\end{tikzpicture}

\end{document}

答案1

你必须改变edge from parent风格

\documentclass[tikz,margin=5mm]{standalone}
\usetikzlibrary{trees}

\begin{document}

\begin{tikzpicture}[level distance=5mm,
    level 1/.style={sibling distance=32mm,
      edge from parent/.style={draw=none}},
    level 2/.style={sibling distance=16mm,
      edge from parent/.append style={draw,dashed}},
    level 3/.style={sibling distance=8mm,level distance=12mm,
      edge from parent/.append style={solid}},
    %level 4/.style={sibling distance=7mm},
    %every fit/.style={rectangle,draw,inner sep=3.5pt},
    grow=right]

\scriptsize
\node {$\bullet$}
child {node {P}
        child {node{PP}
            child {node{PPP}}
            child {node{PPF}}
        }
        child {node{PF}
            child {node{PFP}}
            child {node{PFF}}
        }
    }
child {node {F}
        child {node{FP}
            child {node{FPP}}
            child {node{FPF}}
        }
        child {node{FF}
            child {node{FFP}}
            child {node{FFF}}
        }
    } ;
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容