Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are several ways to prevent labels from overlapping in rpart.plot:

  1. Increase the size of the plot: You can increase the size of the plot by adjusting the width and height parameters in the rpart.plot() function. This can help to reduce label overlap.

  2. Increase the font size of the labels: You can increase the font size of the labels by adjusting the cex parameter in the text.col parameter of the rpart.plot() function.

  3. Use line breaks in the labels: You can add line breaks in the labels by using the paste() function and inserting "\n" where a line break is needed. This can help to split up long labels and prevent label overlap.

  4. Reduce the number of labels: You can reduce the number of labels by setting the minsplit and minbucket parameters in the rpart() function. This can help to simplify the tree and reduce label overlap.

  5. Rotate the labels: You can rotate the labels by adjusting the rotation parameter in the text.col parameter of the rpart.plot() function. This can help to reposition labels and reduce label overlap.