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/ 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. 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
Making my own graphics device
5 messages · Thomas Levine, Paul Murrell, David Winsemius
On Aug 17, 2014, at 12:58 PM, 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/ 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. 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
I went out searching and thought I had found an answer in the archives, but I see it was authored by you, so it must not have been entirely satisfactory: http://markmail.org/search/?q=list%3Aorg.r-project.r-help+hpgl#query:list%3Aorg.r-project.r-help%20hpgl+page:1+mid:sxly4345y6tbj4dw+state:results I also saw the suggestion from Koenker. The current holder of the rights to the S language (at least on PC's) would be TIBCO. They do list the acronym `hpgl` on one page in the S+ documentation, but it is in the "deprecated functions" section (p 39): http://www.uni-koeln.de/themen/statistik/software/s/v81/functionguide.pdf Good luck.
David Winsemius Alameda, CA, USA
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. 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/
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
Thanks for the further tips! I'll look at the R Internals manual, the other built-in devices, and the RSvgDevice package. And I'm still looking for the S source code, but I have a feeling that I'll wind up writing the device before I find the source code.
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.
While this would be a good idea for pretty much any other file format, it probably will make things more complicated for HPGL as the structure of base R graphics is kind of exactly the same as HPGL. Tom