[R] Making my own graphics device

David Winsemius dwinsemius at comcast.net
Mon Aug 18 00:23:43 CEST 2014


On Aug 17, 2014, at 2:35 PM, Paul Murrell wrote:

> Hi
> 
> On 08/18/14 07:58, Thomas Levine wrote:
>> I want to make my own graphics device am thus looking for
>> documentation about graphics devices.
>> 
>> The only thing I've found so far is these directions for
>> making graphics devices with the RGraphicsDevice package.
>> http://www.omegahat.org/RGraphicsDevice/
> 
> That is certainly a good way to get something going quickly at least
> (I used it just the other day and had something up and running in under an hour, based on the inst/examples/SVG/svgDev.R example)
> 
>> Could someone point me to any other resources? Or just
>> some documentation about how to edit base R? If I don't
>> get anything, I'm just going to stare at the grDevices
>> section of the R source code (src/library/grDevices/src)
>> until I figure out how it works.
> 
> The "canonical" approach is to look at the source code for one of the built-in devices in the R source code and change it to do what you want (e.g., src/modules/X11/devX11.c).  The file src/include/R_ext/GraphicsDevice.h has comments describing how the graphics device should be set up.  See the RSvgDevice package for an example of a device implemented in a package.

It may be useful to look at existing interfaces to an HPGL device in other graphics applications. One such application is xgraph and here is the C code for one implementation:

http://xgraph.sourcearchive.com/documentation/12.1-3/hpgl_8c-source.html

The other option might be to enlist an external program such as GNUPLOT that has an HPGL output and use it as a driver to which you send an image in a file format that R can produce.

-- 
David.
> 
> Paul
> 
>> In case you're curious, I want to make a graphics device
>> that saves the graph in Hewlett-Packard Graphics Language.
>> https://en.wikipedia.org/wiki/HPGL
>> 
>> Thanks
>> 
>> Tom
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> -- 
> 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/
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list