2

I'm trying to remove the labels of the Node id's at the terminal panel of a partykit object (those that say Node x...), following the instructions with terminal_panel, I can change the inner_panel without trouble, but the plot includes information of the object instead of the bars:

library(partykit)
ea = ctree(Species ~ ., data = iris)

plot(ea, gp = gpar(fontsize = 8),    
     inner_panel = node_inner,
     ip_args=list(
       abbreviate = F, 
       id = FALSE),
     terminal_panel = node_terminal, 
     tp_args = list(digits = 2, abbreviate = T, id = F))

Which plots the following,

l

Elio Diaz
  • 566
  • 2
  • 19

1 Answers1

3

I think you can remove some arguments to get your desired output. This code removes the "Node x" label and plots the bars for each terminal node

plot(ea,
  gp = gpar(fontsize = 8),
  inner_panel = node_inner,
  ip_args = list(
    abbreviate = F,
    id = FALSE
  ),
  tp_args = list(id = FALSE)
)

Does that solve your problem?

hfshr
  • 118
  • 1
  • 7
  • yes, it worked, removing the terminal panel from the arguments – Elio Diaz Apr 28 '20 at 17:01
  • You can also add `terminal_panel = node_barplot` again. The problem was that you used `node_terminal` rather than `node_barplot`. The former tries to come up with a textual representation in the terminal nodes that includes all the information stored in the tree. Hence, this looked so messy in plot in the question. BTW: If this solved your problem, please accept that answer so that it gets flagged accordingly here on StackOverflow. – Achim Zeileis Apr 28 '20 at 21:20