From p.murrell at auckland.ac.nz  Mon Aug  9 01:08:05 2010
From: p.murrell at auckland.ac.nz (Paul Murrell)
Date: Mon, 09 Aug 2010 11:08:05 +1200
Subject: [Rd] gpar fill and transparency on devices
In-Reply-To: <AANLkTinLv5dTEBRwtMbZr47f3qoTP3AYh-s9TM-AfaBb@mail.gmail.com>
References: <AANLkTi=KXs+c=A1sH_NSc2rD883tXt+8WgMwqHrVLr+r@mail.gmail.com>	<4C5B4137.3080801@auckland.ac.nz>
	<AANLkTinLv5dTEBRwtMbZr47f3qoTP3AYh-s9TM-AfaBb@mail.gmail.com>
Message-ID: <4C5F38D5.1030103@auckland.ac.nz>

Hi

On 6/08/2010 5:34 p.m., baptiste auguie wrote:
> Hi,
>
> Thanks for pointing this out. I do have the book, unfortunately I left
> it abroad this year. I would think that such brief mention in ?gpar
> could be useful (because that's where one first looks for gpar()
> defaults --- which are not listed).

Righto.  I've added a mention in ?gpar

Paul

> Best regards,
>
> baptiste
>
>
> On 6 August 2010 00:54, Paul Murrell<p.murrell at auckland.ac.nz>  wrote:
>> Hi
>>
>> The help page for "Working with Viewports" (e.g., pushViewport()) has a
>> brief mention when talking about the ROOT viewport ...
>>
>> "The viewport tree always has a single root viewport (created by the system)
>> which corresponds to the entire device (and default graphical parameter
>> settings)."
>>
>> ... which is a reasonable place for it because this is a feature of the gpar
>> of the ROOT viewport, not of gpars in general.  That mention might be a bit
>> hard to find, but a very similar statement is also made in the Section on
>> Viewports in the R Graphics book.  That in turn might be hard to find if you
>> don't have the book, but that chapter is also available online
>> (http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf)
>>
>> It might be worth adding something more explicit about this sort of gotcha
>> ...
>>
>> "Some devices have different default graphics parameter settings, so it is
>> not safe to assume that the ROOT viewport will be identical on different
>> devices."
>>
>> ... ?
>>
>> Paul
>>
>> On 5/08/2010 8:14 a.m., baptiste auguie wrote:
>>>
>>> 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
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>> --
>> Dr Paul Murrell
>> Department of Statistics
>> The University of Auckland
>> Private Bag 92019
>> Auckland
>> New Zealand
>> 64 9 3737599 x85392
>> paul at stat.auckland.ac.nz
>> http://www.stat.auckland.ac.nz/~paul/
>>
>
>
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



[Rd] gpar fill and transparency on devices
Paul Murrell