The partykit
package plots barplots at the terminal nodes of trees which gives a visual rendition of the posterior probabilities of the dependent variable classes.
I would like to add those barplots also in the inner nodes, below the standard circles/ellipses. This needs to use a function that is a mixture of node_inner()
and node_barplot()
to the inner_panel
argument of the plot()
method.
But those function have pretty complex internals and I'm not sure how to mix the two in order to have to inner plots stacked vertically.
Any ideas?
It's possible, it just doesn't look very appealing. If you want to show the name of the splitting variable and the p-value, it would be better to tweak the
mainlab
argument ofnode_barplot
. In the answer to Ctree classification with weights - results displayed there is in illustration how to include weights in the title - in a similar fashion you could display splitting variable and p-value.If you are determined to set up a new panel function that has two subpanels, you need a little bit of
grid
programming (the graphics system that theplot()
method is based on). You need to set up agrid.layout
and then go through the resultingviewport
s.With the resulting panel function you can then do: