[R] Source code for R graphics devices

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jul 10 22:26:49 CEST 2006

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 

Duncan Murdoch
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 10-Jul-06                                       Time: 20:52:46
> ------------------------------ XFMail ------------------------------
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

More information about the R-help mailing list