To be a little less terse:

I agree that notes/discussion about what recordPlot/replayPlot do when
there is no display list and that non-interactive devices don't create a
displaylist by default but can be instructed to do so via dev.control (at
least some, I don't claim to have checked them all) would probably be
helpful, as well as a see also link to dev.control.

~G



On Tue, Sep 24, 2013 at 11:25 AM, Gabriel Becker <gmbecker@ucdavis.edu>wrote:

> Henrik,
>
> This works for me:
>
> > png("test.png")
> > dev.control(displaylist="enable")
> > plot(1:10)
> > rp = recordPlot()
> > dev.off()
> X11cairo
>        2
> > rp
>
> HTH,
> ~G
>
> sessionInfo():
> R version 3.0.1 (2013-05-16)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=C                 LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tools_3.0.1
>
>
>
> On Tue, Sep 24, 2013 at 11:14 AM, Henrik Bengtsson <hb@biostat.ucsf.edu>wrote:
>
>> 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
>>
>> ______________________________________________
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
>
> --
> Gabriel Becker
> Graduate Student
> Statistics Department
> University of California, Davis
>



-- 
Gabriel Becker
Graduate Student
Statistics Department
University of California, Davis

	[[alternative HTML version deleted]]

