画小线

画小线

我有以下场景树在此处输入图片描述

 \begin{forest}
 [,name=a,for tree={s sep=50pt,l sep=5cm,dot,grow=1},
     [ ,name=b, edge=dashed
        [ ,name=c, edge=dashed ]
        [ ,name=i, edge=densely dotted  ]
        [,name=d, ]    
     ]
      [ ,name=j,  edge=densely dotted
        [ ,name=k,edge=dashed   ]
        [ ,name=l,edge=densely dotted ]
        [,name=m, ]    
      ]
      [ ,name=e, edge
         [ ,name=f,edge=dashed ]
         [,name=g, edge=densely dotted ]
         [ ,name=h,  ]
      ]
  ]
 \node[xshift=-0.5cm,font=\small] at (a) {$n1$};
 \node[xshift=-0.5cm, font=\small] at (e) {$n2$};
  \node[xshift=-0.3cm,yshift=0.3cm, font=\small] at (j) {$n3$};
  \node[yshift=-0.5cm, font=\small] at (b) {$n4$};
 \node[yshift=0.5cm,font=\small] at (h) {$n5$};
  \node[yshift=0.5cm, font=\small] at (g) {$n6$};
  \node[yshift=0.5cm, font=\small] at (f) {$n7$};
   \node[yshift=0.5cm, font=\small] at (m) {$n8$};
   \node[yshift=0.5cm, font=\small] at (l) {$n9$};
   \node[yshift=0.5cm, font=\small] at (k) {$n10$};
  \node[yshift=0.5cm, font=\small] at (d) {$n11$};
   \node[yshift=0.5cm, font=\small] at (i) {$n12$};
   \node[yshift=0.5cm, font=\small] at (c) {$n13$};
   \node[xshift=1cm, font=\small] at (h) {$s1$};
   \node[xshift=1cm, font=\small] at (g) {$s2$};
  \node[xshift=1cm, font=\small] at (f) {$s3$};
   \node[xshift=1cm, font=\small] at (m) {$s4$};
  \node[xshift=1cm, font=\small] at (l) {$s5$};
  \node[xshift=1cm, font=\small] at (k) {$s6$};
  \node[xshift=1cm , font=\small] at (d) {$s7$};
  \node[xshift=1cm, font=\small] at (i) {$s8$};
  \node[xshift=1cm, font=\small] at (c) {$s9 $};
  \node[yshift=-8cm,name= tiii,font=\small] at (a) {Summer};
  \node[name= tii,font=\small] at (c|-tiii) {Winter};
  \node[name= t,font=\small] at (b|-tii) {Spring};
   \node[xshift=-7cm  ,yshift= 7cm, font=\small] at (a) {scenaio 1} ;
  \node[xshift=-6cm  ,yshift= 6cm, font=\small] at (a) {scenario 2} ;
  \node[xshift=-5cm  ,yshift= 5cm, font=\small] at (a) {scenario 3} ;
  \end{forest}

我想在左上角写 3 条短线,其中一条是点线,另一条是虚线,以对应每个场景......我该怎么做?

谢谢!

答案1

像这样?

在此处输入图片描述

我只是勾勒出场景节点,然后使用这些名称来画线:

   \node[xshift=-7cm  ,yshift= 7cm, font=\small] at (a) (sce1) {scenaio 1} ;
  \node[xshift=-6cm  ,yshift= 6cm, font=\small] at (a) (sce2) {scenario 2} ;
  \node[xshift=-5cm  ,yshift= 5cm, font=\small] at (a) (sce3) {scenario 3} ;
  \draw[densely dotted] ([xshift=3pt]sce1.east) -- ++(15pt,0);
  \draw[dashed] ([xshift=3pt]sce2.east) -- ++(15pt,0);
  \draw ([xshift=3pt]sce3.east) -- ++(15pt,0);

完整代码:

\documentclass{standalone}
\usepackage{forest}

\tikzset{dot/.style={fill,circle,inner sep=1.3pt}}

\begin{document}

 \begin{forest}
 [,name=a,for tree={s sep=50pt,l sep=5cm,dot,grow=1},
     [ ,name=b, edge=dashed
        [ ,name=c, edge=dashed ]
        [ ,name=i, edge=densely dotted  ]
        [,name=d, ]    
     ]
      [ ,name=j,  edge=densely dotted
        [ ,name=k,edge=dashed   ]
        [ ,name=l,edge=densely dotted ]
        [,name=m, ]    
      ]
      [ ,name=e, edge
         [ ,name=f,edge=dashed ]
         [,name=g, edge=densely dotted ]
         [ ,name=h,  ]
      ]
  ]
 \node[xshift=-0.5cm,font=\small] at (a) {$n1$};
 \node[xshift=-0.5cm, font=\small] at (e) {$n2$};
  \node[xshift=-0.3cm,yshift=0.3cm, font=\small] at (j) {$n3$};
  \node[yshift=-0.5cm, font=\small] at (b) {$n4$};
 \node[yshift=0.5cm,font=\small] at (h) {$n5$};
  \node[yshift=0.5cm, font=\small] at (g) {$n6$};
  \node[yshift=0.5cm, font=\small] at (f) {$n7$};
   \node[yshift=0.5cm, font=\small] at (m) {$n8$};
   \node[yshift=0.5cm, font=\small] at (l) {$n9$};
   \node[yshift=0.5cm, font=\small] at (k) {$n10$};
  \node[yshift=0.5cm, font=\small] at (d) {$n11$};
   \node[yshift=0.5cm, font=\small] at (i) {$n12$};
   \node[yshift=0.5cm, font=\small] at (c) {$n13$};
   \node[xshift=1cm, font=\small] at (h) {$s1$};
   \node[xshift=1cm, font=\small] at (g) {$s2$};
  \node[xshift=1cm, font=\small] at (f) {$s3$};
   \node[xshift=1cm, font=\small] at (m) {$s4$};
  \node[xshift=1cm, font=\small] at (l) {$s5$};
  \node[xshift=1cm, font=\small] at (k) {$s6$};
  \node[xshift=1cm , font=\small] at (d) {$s7$};
  \node[xshift=1cm, font=\small] at (i) {$s8$};
  \node[xshift=1cm, font=\small] at (c) {$s9 $};
  \node[yshift=-8cm,name= tiii,font=\small] at (a) {Summer};
  \node[name= tii,font=\small] at (c|-tiii) {Winter};
  \node[name= t,font=\small] at (b|-tii) {Spring};
   \node[xshift=-7cm  ,yshift= 7cm, font=\small] at (a) (sce1) {scenaio 1} ;
  \node[xshift=-6cm  ,yshift= 6cm, font=\small] at (a) (sce2) {scenario 2} ;
  \node[xshift=-5cm  ,yshift= 5cm, font=\small] at (a) (sce3) {scenario 3} ;
  \draw[densely dotted] ([xshift=3pt]sce1.east) -- ++(15pt,0);
  \draw[dashed] ([xshift=3pt]sce2.east) -- ++(15pt,0);
  \draw ([xshift=3pt]sce3.east) -- ++(15pt,0);
  \end{forest}


\end{document}

相关内容