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. -- Daehyok Shin (Peter) Geography Department Univ. of North Carolina-Chapel Hill
On 05/15/04 16:53, Shin wrote:>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.Probably the easiest way is simply to save the code that you used to make the graphic, edit the code, and run it again. This is a good way to work with R anyway. If, for some reason, the graphics tools available for R are not sufficient - and I find this hard to imagine - you can also save graphics as xfig files and then edit them with xfig, assuming that you are using Unix/Linux. Jon -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron
Is it so difficult to develop a function or an object to generate all the code automatically in R? Daehyok Shin (Peter) Terrestrial Hydrological Ecosystem Modellers Geography Department University of North Carolina-Chapel Hill sdhyok at email.unc.edu "We can do no great things, only small things with great love." - Mother Teresa> -----Original Message----- > From: Jonathan Baron [mailto:baron at psych.upenn.edu] > Sent: Saturday, May 15, 2004 PM 10:36 > To: Shin > Cc: R Help > Subject: Re: [R] How to restore and edit saved graphics? > > > On 05/15/04 16:53, Shin wrote: > >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. > > Probably the easiest way is simply to save the code that you used > to make the graphic, edit the code, and run it again. This is a > good way to work with R anyway. > > If, for some reason, the graphics tools available for R are not > sufficient - and I find this hard to imagine - you can also save > graphics as xfig files and then edit them with xfig, assuming > that you are using Unix/Linux. > > Jon > -- > Jonathan Baron, Professor of Psychology, University of Pennsylvania > Home page: http://www.sas.upenn.edu/~baron >
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. :
Thanks for the interesting solution. 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. Thanks again. Daehyok Shin (Peter)> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Gabor Grothendieck > Sent: Saturday, May 15, 2004 PM 11:59 > To: r-help at stat.math.ethz.ch > 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. > : > > ______________________________________________ > R-help at stat.math.ethz.ch 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