Re: [R] Source code for R graphics devices

From: Duncan Murdoch <>
Date: Tue 11 Jul 2006 - 06:26:49 EST

On 7/10/2006 3:52 PM, (Ted Harding) wrote:
> Hi Folks,
> I'm trying to locate the source code for a (typical)
> R graphics device, in order to study how it's done.
> The underlying reason is that I'm thinking of trying
> to create a graphics device for 'pic' (the diagram
> drawing component of [g]troff).
> I thought the xfig device would be a good place to
> look, since the format of an xfig file is similar in
> nature (though very different in detail) to 'pic' code.
> When, in R, I type "xfig" to see the R code, I get the
> line
> .Internal(XFig(file, old$paper, old$family, old$bg, old$fg,
> old$width, old$height, old$horizontal, old$pointsize,
> old$onefile, old$pagecentre))
> so I tried to locate the code for the Internal function "Xfig".
> I can't seem to find it!
> So where should I be looking?

The devices are in the grDevices package. Look in the src directory there for the C code. XFig is in the devPS.c file.

Duncan Murdoch

> Also -- a more general question on this topic -- presumably
> any R graphics device is driven by a "stream" of raw graphics
> data in some presumably device-independent format, which it
> then translates. Where can I find this, and information on
> its structure?
> With thanks, and best wishes,
> Ted.
> PS Total newbie on this front!

Then it might be worth mentioning that this code isn't distributed with a binary version of R, you need a source tarball, and need to look in src/library/grDevices/src.

Duncan Murdoch
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <>
> Fax-to-email: +44 (0)870 094 0861
> Date: 10-Jul-06 Time: 20:52:46
> ------------------------------ XFMail ------------------------------
> ______________________________________________
> mailing list
> PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Tue Jul 11 06:31:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 11 Jul 2006 - 08:15:30 EST.

Mailing list information is available at Please read the posting guide before posting to the list.