[R] using alpha transparency for lines in levelplot

Michael Sumner mdsumner at utas.edu.au
Tue Mar 27 06:01:21 CEST 2007


Deepayan Sarkar wrote:
>
> I don't understand what you are trying to say. Here's a modified
> version of your code:
>
>

Sorry, it's not that the transparency affects the plot regions but the 
colour of the lines darkens the region
colours. I.e. with grey lines the regions are greyed. In your PDF the 
regions are greyed (darker)
in both plots than the colours I see with the usual lattice colour scheme.
Do you notice any difference between the region colours of the plots if 
you write
them to separate files?

If not it must be my viewer.

Cheers, Mike.

> ------------------
> ## panel function to add lines with grey(0.3)
> my.panel <- function(...) {
>    panel.xyplot(1:60, runif(60, 1, 60), type = "l", lwd = 3,
>                 col = grey(0.3))
>    panel.contourplot(...);
>    panel.xyplot(1:60, runif(60, 1, 60), type = "l", lwd = 3,
>                 col = grey(0.3))
> }
>
> ## panel function to add lines with grey transparency
> my.paneltransp <- function(...) {
>   panel.xyplot(1:60, runif(60, 1, 60), type = "l", lwd = 3,
>                col = rgb(0.3, 0.3, 0.3, 0.5))
>   panel.contourplot(...)
>   panel.xyplot(1:60, runif(60, 1, 60), type = "l", lwd = 3,
>                col = rgb(0.3, 0.3, 0.3, 0.5))
> }
>
> pdf("alpha.pdf", version = "1.4")
>
> ## this works fine
> levelplot(z~x+y, xy, panel = my.panel)
>
> ## this doesn't?
> levelplot(z~x+y, xy, panel = my.paneltransp)
>
> dev.off()
> ------------------
>
> and the resulting 2-page PDF file is at
>
> http://dsarkar.fhcrc.org/R/alpha.pdf
>
> I don't see any evidence of transparency in the 'region' colors (the
> lines behind the level plot never show up). Are you sure whatever you
> are seeing is not an artifact of your display application?
>
> Deepayan
>
>



More information about the R-help mailing list