Since my real tree is too wide, I want to move and resize the node label -X_0+X_1>0
so that the red box at the end gets smaller because it dynamically adjusts its size to the nodes.
The arrows and extra text in the image are just for clarification (sorry if it confuses). If you know a solution to resize all node labels that would be even better, but in addition I only want to move the label of this specific node.
I want to format the content of a node, i.e. move and scale the label of the node (not an edge) in the forest package with decision tree forest style.
\forestset{
declare toks={elo}{}, % Edge Label Options
anchors/.style={anchor=#1,child anchor=#1,parent anchor=#1},
dot/.style={tikz+={\fill (.child anchor) circle[radius=#1];}},
dot/.default=2pt,
decision edge label/.style n args=3{
edge label/.expanded={node[midway,auto=#1,anchor=#2,\forestoption{elo}]{\strut$\unexpanded{#3}$}}
},
decision/.style={if n=1
{decision edge label={left}{east}{#1}}
{decision edge label={right}{west}{#1}}
},
decision tree/.style={
for tree={
s sep=0.5em,l=8ex,
if n children=0{anchors=north}{
if n=1{anchors=south east}{anchors=south west}},
math content,
},
anchors=south, outer sep=2pt,
dot=3pt,for descendants=dot,
delay={for descendants={split option={content}{;}{content,decision}}},
}
}
% Source: https://tex.stackexchange.com/a/445950/279450
\tikzset{
rdot/.style = {circle, fill, minimum size=#1,
inner sep=0pt, outer sep=0pt, draw=black, fill=black},
rdot/.default = 4pt % size of the circle diameter
}
\begin{forest} decision tree
[{},plain content,tikz={
\node [draw,red,loosely dashed, fit=()(!1)(!2)]{};
\node [rdot] at (!0.anchor) {};
}
[{$-X_0+X_1>0$};{},plain content,elo={yshift=4pt}
[{};{},plain content]
[{};{},plain content]
] {}
[{};{},plain content
[{};{},plain content]
[{};{},plain content]
] {}
] {}
\end{forest}
The label should not be from an edge, because in my real tree there are separate edge labels and the respective label should logically be attached to the node.
Not filling in the node content and drawing a separate tikz node is not an option, as the red dotted box is dynamically aligned with the node and thus the node content.
If you adjust the position of the node, the whole node will be moved. However, in the forest documentation there is an option to format only the node content. However, I have not been able to find an example of this to make sure that this is the correct option, nor figured I out how to use it.
Is it possible to move and scale only the content of the node, but keep the logical connection with the node, so that the anchors on the nodes still refer to the content of the node?
font=\scriptsize
for example, or you can change the anchor.