Home>
If i execute the following source code with reference to the above URL,
The branches are slanted, and some areas may overlap with labels.
Therefore, I want to make horizontal and vertical branches like the following URL.
Applicable source code
library(rpart)
library(partykit)
library(ggplot2)
library(ggparty)
df<- read.csv("test.csv",header=T)
head(df)
rt<- rpart(kotae ~ A + B + C + D + E + F + G ,data = df, control=rpart.control(minsplit=5, cp=0.007)) # + H + I
prt<- as.party(rt)
g<- ggparty(prt, terminal_space = 0.45) # What percentage of the graph part occupies (from bottom)
g<- g + geom_edge(size = 2) # branch line thickness
g<- g + geom_edge_label(colour = "black", size = 4.5)# text size of branch
g<- g + geom_node_plot(
  gglist = list(geom_boxplot(aes(x="",y=displacement)),theme_bw(base_size =13)), # vertical axis character size
   scales = "fixed",
   id = "terminal",
   shared_axis_labels = TRUE,
   shared_legend = TRUE,
   legend_separator = TRUE,
 )
g<- g + geom_node_label(
   aes(col = splitvar),
   line_list = list(aes(label = paste("Node", id)),
                    aes(label = splitvar)),
   line_gpar = list(list(
     size = 8, character size of #Node
     col = "black",
     fontface = "bold"
   ),
   list(size = 14)), # size of variable A
   ids = "inner"
 )
g<- g + geom_node_label(
   aes(label = paste0("Node ", id, ", N = ", nodesize)),
   fontface = "bold",
   ids = "terminal",
   size = 3, # size of title above graph
   nudge_y = 0.01 # width of graph and title
 )
g<- g + theme(legend.position = "none")
plot(g)
What I tried

I am trying the following in the last output, but it doesn't work.
plot(rt)
→ No

text(rt, use.n=TRUE, cex=0.5)
→ No

plot(as.party(rt))
→ No

Supplemental information (FW/tool ​​version, etc.)

Please provide more detailed information here.