Adrian
Adrian

Reputation: 9793

changing font size in regression tree plot

library(rpart)
library(rpart.plot)
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
prp(fit, type = 4, extra = 101, leaf.round = 1, fallen.leaves = TRUE,
    varlen = 0, tweak = 0.8)

enter image description here

I'm trying to get the text to fit inside the rounded squares. I tried lowering the tweak and cex values, but it appears that the rounded squares get smaller along with the text. How can I make the font size smaller?

Upvotes: 2

Views: 22977

Answers (2)

Nemesi
Nemesi

Reputation: 801

Using the same package - rpart.plot

fancyRpartPlot(fit,cex=3)

Change cex as better suites your case, as explained by Otto_k.

Upvotes: 0

Otto_K
Otto_K

Reputation: 341

Try out this graphical package instead:

library(maptree)
draw.tree(fit,cex=3)

Change cex to get different font sizes.

Upvotes: 4

Related Questions