Unfortunately a bug has been introduced into the recordPlot/replayPlot internal code, so what is saved is the current display list and not a snapshot. (For cognescenti, especially Paul M: duplicate() is required or the saved object will get a pointer to the actual display list.) There are many ways to work around this, but using save/load is a good one.
In R-patched you can just do plot(1:10) myplot <- recordPlot() title(main="My Title") myplot title(main="My Other Title") but in R 1.9.0 you need to do something like plot(1:10) myplot <- recordPlot() save("myplot", file="myplot") title(main="My Title") load("myplot") myplot title(main="My Other Title") On Sun, 16 May 2004, Prof Brian Ripley wrote: > The display list on a screen device is enabled unless you explicitly > disable it, and if you know how to do that you will understand the help > for recordPlot, which says that it saves the display list so there had > better be one. > > I suspect only a handful of R users have ever used dev.control and I am > not one of them. I only added the ability to re-enable the display list > for a single user's very specific problem. > > On Sun, 16 May 2004, Shin, Daehyok wrote: > > > Thanks for the interesting solution. > > But it is not a solution. You asked how to `restore and edit saved > graphs'. recordPlot saves graphs, and does not allow you to edit them. > > > I am happy to find a way to save all graphic options into a file. > > There is a minor glitch. > > Is there is any way to replace title, not to overwrite it? > > And if I want to change the color of a line or the ranges of x or y axis, > > how can I do it with the restored plot? > > > > Interestingly, there is no mention about dev.control() in the help document > > of recordPlot(). I think it should be there. > > See above. > > > Thanks again. > > > > Daehyok Shin (Peter) > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] Behalf Of Gabor Grothendieck > > > Sent: Saturday, May 15, 2004 PM 11:59 > > > To: [EMAIL PROTECTED] > > > Subject: Re: [R] How to restore and edit saved graphics? > > > > > > > > > Saving of the low level graphics that R displays can be > > > 1. turned on with dev.control(displaylist="enable") and > > > 2. turned off with dev.control(displaylist="inhibit"). > > > recordPlot() can be used to save the display list in a variable. > > > > > > For example: > > > > > > # turn on display list, perform plot, turn off display list, add title > > > # do not need next line if graphics device already active > > > windows() # or x11() on unix > > > dev.control(displaylist="enable") > > > plot(1:10) > > > myplot <- recordPlot() > > > dev.control(displaylist="inhibit") > > > title(main="My Title") > > > > > > # now redisplay plot as it was before title and reissue title > > > myplot > > > title(main="My Other Title") > > > > > > Shin <sdhyok <at> email.unc.edu> writes: > > > > > > : > > > : I am looking for a function to restore saved graphics for further > > > : editing, such as changing its title, labels, or legend. > > > : How can I do it in R? Thanks in advance. > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html