[Rd] windows device transparency issue

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Sep 28 08:56:20 CEST 2007


Thank you for trying 2.6.0 RC.

The example is far from minimal: most semi-transparent polygon fills were 
failing due to a typo prior to r43003.  Your example now works (several 
times faster than under Cairo).

As you will see from the below, sending HTML makes your postings 
unnecessarily hard to read for users of text email clients: please do 
follow the posting guide.


On Thu, 27 Sep 2007, Austin, Matt wrote:

>
>
> I read in a thread in r-help today that the windows device in 2.6 supports
> transparency, so I tried an example and had some issues.  The density plots
> should be filled with transparent color in the following example (similar to
> the points), however the color is "fully" transparent.  This works in the
> Cairo device, but not in the windows device.
>
>
>
> Thanks,
>
>
>
> --Matt
>
>
>
> Matt Austin
>
> Statistician, Amgen Inc.
>
>
>
>
>
> Example of problem derived from example(layout) code.
>
>
>
> ##Start
>
> windows()
>
>
>
> x <- pmin(3, pmax(-3, rbeta(5000,1,5)))
>
> y <- pmin(3, pmax(-3, c(rnorm(2500, .25, 1), rnorm(2500))) )
>
> trtp.f <-  factor(rep(c("Placebo", "Not Placebo"), each=2500),
> levels=c("Placebo", "Not Placebo"))
>
>
>
> xdens <-  tapply(x, trtp.f,  density, na.rm=TRUE)
>
> ydens <-  tapply(y, trtp.f,  density, na.rm=TRUE)
>
>
>
> topx <- max(unlist(lapply(xdens, function(x) max(x$y))))
>
> topy <- max(unlist(lapply(ydens, function(x) max(x$y))))
>
>
>
> xrange <- range(x, na.rm=TRUE)
>
> yrange <- range(y, na.rm=TRUE)
>
>
>
> nf <- layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE)
>
>
>
> par(mar=c(4,4,0,0), oma=c(0,0,0,0))
>
>
>
> getcolors <- rainbow(length(levels(trtp.f)), alpha=.5)
>
> plot(x, y, xlim=xrange, ylim=yrange,xlab="X value", ylab="Y value", pch=21,
> bg=getcolors[as.numeric(trtp.f)])
>
>
>
> par(mar=c(0,4,1,1))
>
> plot(x=xrange, axes=FALSE, xlim=xrange, ylim=c(0, topx), xlab="", ylab="")
>
> #lapply(xdens, lines)
>
>
>
> for(i in 1:length(xdens)){
>
>  dat <- xdens[[i]]
>
>  polygon(x=c(min(dat$x), dat$x, max(dat$x)) , y=c(0, dat$y, 0),   col=
> rainbow(length(xdens), alpha=.5)[i])
>
> }
>
>
>
> par(mar=c(4,0,1,1))
>
> plot(x=yrange, axes=FALSE, ylim=yrange, xlim=c(0, topy), xlab="", ylab="")
>
>
>
> for(i in 1:length(ydens)){
>
>  dat <- ydens[[i]]
>
>  polygon(y=c(min(dat$x), dat$x, max(dat$x)) , x=c(0, dat$y, 0),
> col=rainbow(length(ydens), alpha=.5)[i])
>
>
>
> }
>
> ##End
>
>
>
> Other Info:
>
>
>
> platform       i386-pc-mingw32
>
> arch           i386
>
> os             mingw32
>
> system         i386, mingw32
>
> status         RC
>
> major          2
>
> minor          6.0
>
> year           2007
>
> month          09
>
> day            26
>
> svn rev        42991
>
> language       R
>
> version.string R version 2.6.0 RC (2007-09-26 r42991)
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list