[R] contourLines() starts a plot device

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Tue May 24 11:46:00 CEST 2005

Pierre Kleiber wrote:
> I want to use contourLines() to get contour line coordinate vectors, but 
> I don't want to make a plot.  However contourLines() insists on
> opening a graphics device.  Is there a way tell it not to do this?

contourLines() calls .Internal(contourLines(...)), and that calls 
do_contourlines in plot3d.c, and that gets the current graphics device, 
hence activating one if there isn't one (I think), and passes it to 
GEcontourLines... which then seems to do nothing with it at all.

  I just removed 'dd' from the call to GEcontourLines and the arg list 
to GEcontourLines, fixed GraphicsEngine.h to match, recompiled, and now 
my contourLines() function doesn't try to make a new graphics window. I 
can't see GEcontourLines being called from anywhere else, but there may 
be code that calls it, so possibly a better idea may be to pass a NULL 
to it from GEcontourLines to keep the API the same.

  There are some comments scattered around the code about how 
contourLines shouldnt really be a graphics function, so I'm guessing 
there's some thought going into this already by the developers.

  Another possible quick fix for unix systems may be to start a 
PostScript graphics device with file="/dev/null" so that the graphics 
output disappears into thin air.


More information about the R-help mailing list