I’m using the party package in R to create a decision tree with some data. My dependent variable has some long strings and so the horizontal presentation of the x-axis labels means that all levels of my dependent variable are not showing.
Using the survey data from the MASS package as a trivial example, with the party package loaded:
data(survey)
#remove missing value
survey2 <- subset(survey, !is.na(Clap))
TreeResults <- ctree(Clap ~ Sex + Exer + Smoke, data=survey2)
plot(TreeResults)
The labels I wish to rotate are for Clap, and I would like these to print at 45 degrees for each node. My real data has two terminal nodes, just like this example.
I have looked at node_barplot and I cannot see an option within there to modify the orientation of the x-axis labels.
Could someone advise how to do the label reorientation?
Thanks in advance.
Update: printing the labels up the sides as per the suggestion produced this plot:

Did you want something like?
UPDATE OP indicated this was not appropriate.
Unfortunately I cant see an easy fix. You can redefine the
node_barplot()function as follows:all this did was add
rot=to thegrid.textcall whenbeside=Tthen call the following:
SUMMARY:
you can hack the
node_barplotfunction a painless way to do it would be as follows:and use the
altbpwhich will rotate text by 45 degrees.