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:
library("partykit")
packageDescription("partykit")$Version
## [1] "1.0-5"
The tree can be grown as in your example:
airq <- subset(airquality, !is.na(Ozone))
air.ct <- ctree(Ozone ~ ., data = airq)
Then we first add an empty page with a gray background:
grid.newpage()
grid.rect(gp = gpar(col = "gray", fill = "gray"))
Then the tree can be added:
plot(air.ct,
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.