[Rd] gpar fill and transparency on devices

Paul Murrell p.murrell at auckland.ac.nz
Mon Aug 9 01:08:05 CEST 2010


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/



More information about the R-devel mailing list