Re: [Rd] grid graphics gpar(fill) argument and jpeg device

From: Paul Murrell <>
Date: Thu 08 Dec 2005 - 21:32:46 GMT


Florian Hahne wrote:
> Hi everybody,
> I just notice a strange behaviour of gpar's fill argument when using
> non-postscript devices:
> The default of the argument is transparent (according to get.gpar("fill")).
> So as expected, the following code draws a nice red rectangle in the
> middle of my X11 or postscript device.
> pushViewport(viewport(width=0.5, height=0.5))
> grid.rect(gp=gpar(fill="red"))
> grid.rect()
> However, when plotting on a jpeg device (or any other pixel device),
> the output of the above code is an empty (=white) rectangle. Obviously
> the second grid.rect() which should produce a transparent rectangle
> turns out to be filled white on the jpeg device. When I set the fill
> argument to NA, the second rectangle is transparent as it is supposed to be.
> grid.rect(gp=gpar(fill="red"))
> grid.rect(gp=gpar(fill=NA))
> Is this a bug or a feature???
> I'm using R version 2.2.0 on a SUSE 10.0 linux machine.

Feature. The top-level grid viewport (representing the entire device) takes starting values for things like text size, background colour, etc from the device; from R version 2.2, this includes using 'fg' and 'bg' from the device for gpar(col) and gpar(fill). This is so that if you start a device using something like postscript(bg="red"), the gpar(fill) for the top-level grid viewport will be "red".

The default 'bg' for PostScript is "transparent", but for jpeg the default 'bg' is "white".


Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
New Zealand
64 9 3737599 x85392

______________________________________________ mailing list
Received on Fri Dec 09 08:38:13 2005

This archive was generated by hypermail 2.1.8 : Fri 09 Dec 2005 - 11:22:15 GMT