On Oct 7, 2010, at 9:04 AM, Alejo C.S. wrote:

Dear list, I want to plot several variables with splom and in the main
diagonal, instead of the variable names, I'd like to plot an histogram of corresponding variables. Searching I did not find the correct syntax, only some tips in an old post in the list, but this comments help to plot only density lines instead of histograms. I had some code, but it fails to plot
(I've commented the problematic lines):


splom(iris[,1:4], panel = function(x, y, ...) {
        panel.xyplot(x, y, ...)
panel.lmline(x,y,...)
}
#        , diag.panel=function(x,...){
#  panel.histogram(x,...)
#        }

)

Thanks a lot in advance!


From 2007 posting by Barnes (only return from RSiteSearch with modified Targets for "splom diag.panel histogram":

panel.hist.splom<-function(x, ...)
     {
         yrng <- current.panel.limits()$ylim
         h <- hist(x, plot = FALSE)
         breaks <- h$breaks; nB <- length(breaks)
         y <- h$counts; y <- yrng[1] + 0.95 * diff(yrng) * y / max(y)
panel.rect(breaks[-nB], yrng[1], breaks[-1], y, col="cyan", ...)
     }
my.plot = function(data) {
  splom( ~data,
       lower.panel=function(x, y, ...) {
         panel.xyplot(x, y, ...)
         panel.lmline(x,y,...)},
       upper.panel=function(x, y, ...) {
         panel.xyplot(x, y, ...)
         panel.lmline(x,y,...)},
       diag.panel = panel.hist.splom)
}

my.plot(iris[,1:4])


David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org 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