Adding Histograms and Density plots to a splom with gridBase

The following produces a reasonable-looking result:
library(grid)
library(gridBase)
splom(USArrests, diag.panel = function(x, varname, ...) {
    pushViewport(viewport(width = 0.8, height = 0.8))
    opar <- par(fig = gridFIG(), new = TRUE, mar = c(0,0,1,0))
    on.exit(par(opar))
    hist(x, axes = FALSE, main = varname)
    popViewport()
})
It is rather brittle though:

Luke Tierney 2008-10-09