Writing graphics code (was: [R] get vector data from contour)
murdoch at stats.uwo.ca
Wed Feb 7 15:32:43 CET 2001
On Tue, 6 Feb 2001 08:45:20 +1300, Ross Ihaka wrote in message
<20010206084520.A309 at arche.ihaka>:
> I would like to see all R graphics code separated into
>computation and drawing components. This would make a number of things
>easier - eg. replacing the current drawing system with something better.
An alternative to this would be to provide access to the internals of
graphics objects. I'm not familiar with the current internals of
plots in R, but the model I'm trying to implement in a 3D package is
to make graphics objects completely open to manipulation. Since the
3D renderer needs to redraw the image every time it moves anyways, why
not allow the user to change what gets redrawn? But this would be
useful even in static 2D plots, for example to rescale when new data
My current implementation has all of the data residing outside of R's
memory space, with various external functions to read and write it.
It would be better to have it entirely internal (since I'm sure it's
easy to get memory leaks now), but I'm not ready to manipulate R
internal objects yet.
There are basically two types of objects to manipulate: primitives
(which are represented as vectors of data) like points, lines and
polygons, and groups, which are lists of objects together with a
transformation matrix. Since groups can contain both primitives and
other groups, there's a hierarchical structure.
The low level functions add a primitive to the currently active group,
and return a pointer to it. Users can use that pointer to move points
around, change colours, etc.
The high level functions draw lots of primitives, and return a
structure with pointers to the outermost group, and sometimes pointers
to key elements within it, or other helpful things. (The design
hasn't settled down yet!)
One issue that I don't know how to address if this was done entirely
with R objects is what to do about all those pointers.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help