Hello,

I am in need of help in putting histograms on the diagonal of a plot 
produced with splom().

The plot matrix I am trying to produce is to have standard scatterplots 
in the upper-left triangle, contour plots in the lower-right triangle, 
and histograms on the diagonal. I have a function that does the first 
two, but the histograms on the diagonal has been beyond my ability.

Here is my function:

require(lattice)
require(MASS)
my.plot = function(data)
{
   splom( ~data
        , lower.panel=function(x,y, ...)
          {
            xy=kde2d(x,y)
            xy.tr=con2tr(xy)
            panel.contourplot( xy.tr$x
                             , xy.tr$y
                             , xy.tr$z
                             , subscripts=seq(nrow(xy.tr))
                             , contour=TRUE
                             , region=TRUE
                             , labels = FALSE
                             , col.regions = terrain.colors
                             )
          }
         , upper.panel=function(x,y, ...)
          {
            panel.grid(-1,-1)
            panel.xyplot(x,y, cex=0.5)
          }
        #, diag.panel=function(x, ...)
        #  {
        #    panel.histogram(x, ...)
        #  }
        )
}

It can be called, for example, with:

   my.plot(subset(iris, select = Sepal.Length:Petal.Width))

(the subset is necessary to get rid of a variable that is a factor; my 
function can not deal with factors).

I have commented out my best guess at the code needed to produce the 
histograms along the diagonal, which fails.

Any guidance would be greatly appreciated.

best regards,
Marc

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to