フォレスト ツリー ノードに進行状況バーを追加するにはどうすればよいでしょうか?

フォレスト ツリー ノードに進行状況バーを追加するにはどうすればよいでしょうか?

ツリー内のいくつかのノードの下に進行状況バーを追加したいと思います。

このようなもの:

ここに画像の説明を入力してください

私のツリーコードは次のとおりです:

\package{forest}
\begin{document}
\begin{forest}
for tree={calign=fixed edge angles},
[Asp \textsubscript{Habitual} [solere\\]
[Asp \textsubscript{Predispositional}
[tendere]
[Asp \textsubscript{Repetetive \textsubscript{i}} [tornare]
[Mod \textsubscript{Volition}
[volere][,phantom]
]]]]
\end{forest}
\end{document}

一方、私の進捗バーコードは次のとおりです。

\package{progressbar}
\begin{document}
\progressbar[linecolor=black, filledcolor=green]{0.6}\llap{\raisebox{1.5pt
{\tiny$60\%$}\hspace{0.8cm}} 
\end{document}

これら 2 つを組み合わせるにはどうすればよいですか? 各ノードの後に​​進行状況バー コードを追加しようとしましたが、フォレスト環境内ではコードが機能しないようです。

よろしくお願いします!

答え1

\progressbar内部的に TikZ を使用しており、TikZ 画像をネストするのは面倒なので、\progressbar独自の を作成することを忘れないようにすることができますtikzpicture

バーは非対称に作られているため(左端のポイントはバツ= 0) をマトリックス内に配置し、これをノードのように配置して を使用できるようにしますlabel

progressbar4 つの引数を受け入れるキーを forest に追加しました。

  1. オプションは\progressbar
  2. 進捗値と
  3. テキストノードにオプションを追加する
  4. その内容。

コード

\documentclass[tikz]{standalone}
\usepackage{forest, progressbar}
\forestset{
  progressbar/.style n args={4}{
    label={[matrix, inner sep=+0pt]below:%
      \let\tikzpicture\scope
      \let\endtikzpicture\endscope
      \progressbar[{#1}]{#2}
      \path (Begin) -- node[{midway,anchor=center,node font=\tiny,#3}] {#4\,\%} (End);
      \expandafter\pgfmatrixendrow}}}
\progressbarchange{linecolor=black, filledcolor=green}
\begin{document}
\begin{forest} for tree={calign=fixed edge angles}
[Asp \textsubscript{Habitual}
  [solere, progressbar={}{.6}{}{60}]
  [Asp \textsubscript{Predispositional}
    [tendere, progressbar={filledcolor=yellow}{.3}{}{30}]
    [Asp \textsubscript{Repetetive \textsubscript{i}}
      [tornare]
      [Mod \textsubscript{Volition}
        [volere, progressbar={filledcolor=blue, width=1cm}{.85}{white}{85}]
        [,phantom]
      ]
    ]
  ]
]
\end{forest}
\end{document}

出力

ここに画像の説明を入力してください

答え2

私は、バーを配置したいターミナルノードの後に​​次のコードを指定することによってこの問題を解決しました。

[volere, tikz={\node[below=-2.5pt of .south]  
{\progressbar[linecolor=black, filledcolor=green]{0.6}\llap{\raisebox{1.5pt
{\tiny$60\%$}\hspace{0.8cm}}};}]

完全なコードは次のとおりです。

\usepackage{tikz}
\usepackage{forest}
\begin{document}
\begin{forest}
 for tree={calign=fixed edge angles},
 [Asp \textsubscript{Habitual} [solere]
 [Asp \textsubscript{Predispositional}
 [tendere]
 [Asp \textsubscript{Repetetive \textsubscript{i}} [tornare]
 [Mod \textsubscript{Volition}
 [volere, tikz={\node[below=-2.5pt of .south]  { \progressbar[linecolor=black, filledcolor=green]{0.6}\llap{\raisebox{1.5pt}{\tiny$60\%$}\hspace{0.8cm}}};}][,phantom]
 ]]]]
\end{forest}
\end{document}

関連情報