How to change plot background of a ctree object in R?

I'm making a tree using the party package for a poster, and the background of the poster is grey. I've been able to change the background of all of my other plots (box plots, scatter plots) to grey by using the command par(bg = "grey") but this doesn't work for ctree.

For example, this makes a scatter plot on a grey background:

airq <- subset(airquality, !
plot(Temp ~ Wind, data = airq)

But this does not make a tree on a grey background:

air.ct <- ctree(Ozone ~ ., data = airq)
par(bg = "grey")
plot(air.ct, inner_panel=node_inner(air.ct, pval = TRUE, id = FALSE),
  terminal_panel = node_boxplot(air.ct, id = FALSE))

Please help, my poster is due on Thursday!


Both the party package and its successor partykit are based on the grid package for visualization. Therefore, the par() function for base graphics is ignored when creating grid graphics. For the latter, there is a gpar() function but it does not directly support setting a bg background.

Therefore, in the current version of party or partykit setting the background color is not possible via simple arguments - only by supplying adapted panel functions.

However, as this feature was already partially supported in some panel functions, I've adapted the partykit package on R-Forge to enable setting backgrounds. The most recent version of the package is required for this:

## [1] "1.0-5"   

The tree can be grown as in your example:

airq <- subset(airquality, !
air.ct <- ctree(Ozone ~ ., data = airq)

Then we first add an empty page with a gray background:

grid.rect(gp = gpar(col = "gray", fill = "gray"))

Then the tree can be added:

  ip_args = list(id = FALSE, fill = "gray"),
  ep_args = list(fill = "gray"),
  tp_args = list(id = FALSE, bg = "gray", fill = "slategray"),
  newpage = FALSE

To obtain this development version of partykit, please go to the R-Forge page of the package. There you can either check out the source package (see "SCM") and install it by hand - or you can wait until a new package has been built (see "R Packages"). The latter should hopefully be completed in a few hours.

Need Your Help

transfering a variable to another page in windows phone 7

c# silverlight windows-phone-7 xaml

Im trying to transfer a string-variable to another page. In Main Page code looks like:

Hovering over different segments in a circle

javascript jquery html css

I am currently trying to create a blue, circular, pie-chart-esque image for my website. The circle will be split into 6 different segments.