From baptiste.auguie at googlemail.com  Wed Aug  4 22:14:28 2010
From: baptiste.auguie at googlemail.com (baptiste auguie)
Date: Wed, 4 Aug 2010 22:14:28 +0200
Subject: [Rd] gpar fill and transparency on devices
Message-ID: <AANLkTi=KXs+c=A1sH_NSc2rD883tXt+8WgMwqHrVLr+r@mail.gmail.com>

Dear list,

I'm puzzled by the graphical output in the following example,

library(grid)

foo <- function(){
  grid.rect(gp=gpar(fill="black"))
  print(get.gpar()$fill)
  grid.rect(width=0.2,height=0.2)
}

png("test.png", bg = "transparent")
foo()
dev.off()

png("test1.png", bg = "white")
foo()
dev.off()


It seems that the default value of gpar()$fill is set according to the
device background. I couldn't find this documented in ?gpar or in
?png, and it caused a rather puzzling bug in my code (the pdf() output
was OK, whilst the png output (default bg to white) was seemingly
empty because covered by a white rectangle.)

Best regards,

baptiste



[Rd] gpar fill and transparency on devices
baptiste auguie