Is there any way to change the title sizes of a ctree plot?
Use the following variables to quickly set up a ctree plot
a<-c(41, 45, 50, 50, 38, 4
There is good news and bad news.
So the plot()
function that's actually doing all the work there is party:::plot.BinaryTree
. The help is available from ?plot.BinaryTree
but the bad news is it doesn't have any easily accessible parameters for font formatting. However, the good news is that the function uses grid graphics to draw to the screen and you can update properties after you've created the plot.
So after you run
library(party)
urp<-ctree(a~., data=data.frame(a,p))
plot(urp, main = "Broken Title")
You can run
for(gg in grid.ls(print=F)[[1]]) {
if (grepl("text", gg)) {
print(paste(gg, grid.get(gg)$label,sep=": "))
}
}
to see all the text boxes on the plot. For example, I see
[1] "GRID.text.673: Broken Title"
[1] "GRID.text.677: X1"
[1] "GRID.text.678: p = 0.03"
[1] "GRID.text.680: 1"
[1] "GRID.text.682: phantom(0) <= 1"
[1] "GRID.text.684: phantom(0) > 1"
[1] "GRID.text.686: Node 2 (n = 8)"
[1] "GRID.text.697: Node 3 (n = 109)"
Here i see the node names, and the text they contain. Note that the node names are not the same from plot to plot and change everything you draw the same plot. But you can use this list to find the ones you want to change and update them. So if I wanted to make the main text bigger, I would run
grid.edit("GRID.text.673", gp=gpar(fontsize=20))
or If i wanted to italize the node labels i would run
grid.edit("GRID.text.686", gp=gpar(fontface=3))
grid.edit("GRID.text.697", gp=gpar(fontface=3))
and that gives