-1

I was using the below code, and in the output I was getting a nice conditional shading in each node, depending on the %age of the Target variable (Y/N). Higher the % of Y, darker the shade of green and higher the %age of N, darker the shade of red.

rpart.plot(Rpart_temp, type = 4 , extra =104, digits = 2, cex=1)

Now I am using a new machine, and all I get is a black and white plot. Even if I add rpart.plot(Rpart_temp, type = 4 , extra =104, digits = 2, cex=1 , box.col=c("green", "red")) I dont get the shading effect.

Any ideas? Sorry, I cannot share the plot outputs.

  • Can you please make your question [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Roman Luštrik Mar 24 '17 at 09:01
  • I am not having issues with executing the codes. Just that the outputs (as explained) look different. Sorry, I cannot share the image screenshots though. – Saptarshi Sen Mar 24 '17 at 09:37

1 Answers1

0

Instead of using box.col use box.palette. See the rpart.plot documentation for details:

rpart.plot(Rpart_temp, type = 4 , extra =104, digits = 2, cex=1, 
           box.palette=c("green", "red"))

rpart.plot(Rpart_temp, type = 4 , extra =104, digits = 2, cex=1, 
           box.palette="GnRd") # builtin palette

This requires rpart.plot version 2.0.0 or higher.

Stephen Milborrow
  • 976
  • 10
  • 14