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:
- There is a warning about calling par(new=TRUE) with no plot the
first time thi is used.
- Things get confused if the plot window is resized,
for X11 and quartz devices at least.
- For quartz resizing seems to lead to a segfault.
Luke Tierney 2008-10-09