[R] histogram loses top row with alpha transparency under Windows

Keith Ponting k.ponting at aurix.com
Wed Oct 8 16:15:19 CEST 2008


Hello all. 

Trying to use transparency for overlaid "histogram" plots I have come
across an interesting inconsistency, possibly a bug when running under
Windows. Originally noticed in R 2.7.1, it is still there in 2.8.0 beta.

library(lattice)
zz <- function(n,alpha)
{
  ranges <- NULL
  for(ds in 1:n){
    ranges <-
rbind(ranges,data.frame(confidence=c(0,100),dataset=as.character(ds),cor
rect=c(FALSE,TRUE)))
  }
  panel.colhist = function(x, group.number, col, ...) {
    panel.histogram(x, col=group.number+1, ...)
  }
  x <- histogram(~confidence|dataset,data=ranges,alpha=alpha,
 
panel=panel.superpose,panel.groups=panel.colhist,groups=correct)
  print(x)
}
zz(12,1) # works as expected, 12 identical plots
zz(12,0.5) # top row of plots has no bars at all, lower rows are as
expected
zz(1,1) # two bars fine
zz(1,0.5) # no bars at all

(I also find the default breaks slightly counter-intuitive here, as the
number of breaks seems to depend on the total size of the data, rather
than on the size within each plot - the bars meet in the zz(1,1) case
but are well separated in the zz(12,1) case.)

I am running on 64-bit Windows Vista Business SP1, session info is as
follows:

R version 2.8.0 beta (2008-10-07 r46631) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


other attached packages:
[1] lattice_0.17-15

loaded via a namespace (and not attached):
[1] grid_2.8.0

It appears to work correctly under (Suse) linux, with the following
session characteristics:

R version 2.7.2 (2008-08-25) 
i686-pc-linux-gnu 

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
TF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=
C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATI
ON=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


other attached packages:
[1] lattice_0.17-13

loaded via a namespace (and not attached):
[1] grid_2.7.2

                           sysname                            release 
                           "Linux"            "2.6.22.18-0.2-default" 
                           version                           nodename 
"#1 SMP 2008-06-09 13:53:20 +0200"                           "node76" 
                           machine                              login 
                            "i686"                         "kponting" 
                              user 
                        "kponting"



Keith Ponting
Aurix Ltd, Malvern WR14 3SZ  UK



More information about the R-help mailing list