[R] histogram loses top row with alpha transparency under Windows
Richard Cotton
Richard.Cotton at hsl.gov.uk
Thu Oct 9 14:09:13 CEST 2008
k.ponting wrote:
>
> 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
>
The rectangles being drawn extend higher than the top of the panel. (Your y
axis ranges from 0 to 50, but the bars go up to 100.)
In the top row of plots, depending upon the shape of your device window, the
bars can extend beyond the range of the device window. For some reason,
(take a look in panel.rect), when you specify alpha less than 1, this
prevents the bar being drawn.
You need to add type="count" to the call to histogram, or rescale the bar
heights.
-----
Regards,
Richie.
Mathematical Sciences Unit
HSL
--
View this message in context: http://www.nabble.com/histogram-loses-top-row-with-alpha-transparency-under-Windows-tp19879687p19897501.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list