From hb at biostat.ucsf.edu  Tue Sep 24 20:14:45 2013
From: hb at biostat.ucsf.edu (Henrik Bengtsson)
Date: Tue, 24 Sep 2013 11:14:45 -0700
Subject: [Rd] recordPlot() on non-interactive graphics device?
Message-ID: <CAFDcVCT0P9kHiYkwvYCS03u7CEZd0kd7V00hhtb+-Otb1mVe_Q@mail.gmail.com>

Hi.

Q. Is there a way to record a plot using grDevices::recordPlot()
without opening an interactive (=visible GUI window) graphics device
(not even for a flash of a second)?


Related: help("recordPlot", package="grDevices") says:

"These functions record and replay the displaylist of the current
graphics device."

Is the intention that recordPlot() should be able to record from _any
type_ of graphics device, or only for _interactive_ ones?   For
instance,

windows(); plot(1:10); g <- recordPlot(); dev.off();
x11(); plot(1:10); g <- recordPlot(); dev.off();
Cairo::CairoWin(); plot(1:10); g <- recordPlot(); dev.off();

all produce 'recordplot' objects that replot the figure with
replayPlot(g), whereas for instance

png("foo.png"); plot(1:10); g <- recordPlot(); dev.off();
pdf("foo.pdf"); plot(1:10); g <- recordPlot(); dev.off();

produce "empty" replayPlot(g) outputs.

Q. It it just a coincident that it appear that
recordPlot()/replayPlot() only works for
grDevices::deviceIsInteractive() graphics devices?  If not, should
?recordPlot clarify that "These functions record and replay the
displaylist of the current [interactive] graphics device."?

Q. ...or is just the fact that currently png(), pdf() etc. won't
populate "the displaylist" (whatever that is), but if they would, then
recordPlot()/replayPlot() would indeed generate an non-empty plot?  If
so, a note like "Note, recordPlot() will often record an empty plot on
non-interactive graphics devices as they do not populate the
displaylist." may be add to the help.


Thanks,

Henrik



[Rd] recordPlot() on non-interactive graphics device?
Henrik Bengtsson