John Sorkin
2007-Mar-06 17:43 UTC
[R] Recalling and printing multiple graphs. Is there something in the HISTORY menu that will help?
I have written an R function that produces multiple graphs. I use
par(ask=TRUE) to allow for the inspection of each graph before the next
graph is drawn. I am looking for a way to recall all graphs drawn in an
R session, and a method that can be used to print all the graphs at one
time. I know that I could simply print each graph after I inspect the
graph, but this gets tiresome if one's function produces tens of graphs.
I suspect that if I knew more about the history menu (which currently
has an entry RECORDING) I could get the graphs to be replayed and
printed, but alas I have not been able to find instructions for using
the HISTORY menu. Please take pity on my when you let me know that some
easy search or command could get me the information I needed. I have
looked, but clearly in the wrong places.
John
John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence
University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
jsorkin@grecc.umaryland.edu
Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}
Bert Gunter
2007-Mar-06 19:25 UTC
[R] Recalling and printing multiple graphs. Is there somethingin the HISTORY menu that will help?
See FAQ for Windows 5.2 and the referenced README.
?win.metafile and ?replayPlot might allow you to "replay" the saved
plot
history (by default in .SavedPlots) into a file in emf or wmf format, I
think, but I haven't actually tried this -- don't know if it will work
for
multiple graphs.
Let us know if this approach works if you don't get a definitive answer
elsewhere.
Cheers,
Bert
Bert Gunter
Genentech Nonclinical Statistics
South San Francisco, CA 94404
650-467-7374
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of John Sorkin
Sent: Tuesday, March 06, 2007 9:44 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Recalling and printing multiple graphs. Is there somethingin
the HISTORY menu that will help?
I have written an R function that produces multiple graphs. I use
par(ask=TRUE) to allow for the inspection of each graph before the next
graph is drawn. I am looking for a way to recall all graphs drawn in an
R session, and a method that can be used to print all the graphs at one
time. I know that I could simply print each graph after I inspect the
graph, but this gets tiresome if one's function produces tens of graphs.
I suspect that if I knew more about the history menu (which currently
has an entry RECORDING) I could get the graphs to be replayed and
printed, but alas I have not been able to find instructions for using
the HISTORY menu. Please take pity on my when you let me know that some
easy search or command could get me the information I needed. I have
looked, but clearly in the wrong places.
John
John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence
University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
jsorkin at grecc.umaryland.edu
Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Petr Klasterecky
2007-Mar-06 19:26 UTC
[R] Recalling and printing multiple graphs. Is there something in the HISTORY menu that will help?
options(graphics.record=TRUE) can be used to switch the recording on (MS Windows, not sure about other platforms). See ?options To set this option as default, use .Rprofile It is however quite annoying to examine and save all the graphs manually... You might find functions like postscript(), png(), jpeg() and others useful. Petr John Sorkin napsal(a):> I have written an R function that produces multiple graphs. I use > par(ask=TRUE) to allow for the inspection of each graph before the next > graph is drawn. I am looking for a way to recall all graphs drawn in an > R session, and a method that can be used to print all the graphs at one > time. I know that I could simply print each graph after I inspect the > graph, but this gets tiresome if one's function produces tens of graphs. > I suspect that if I knew more about the history menu (which currently > has an entry RECORDING) I could get the graphs to be replayed and > printed, but alas I have not been able to find instructions for using > the HISTORY menu. Please take pity on my when you let me know that some > easy search or command could get me the information I needed. I have > looked, but clearly in the wrong places. > John > > > John Sorkin M.D., Ph.D. > Chief, Biostatistics and Informatics > Baltimore VA Medical Center GRECC, > University of Maryland School of Medicine Claude D. Pepper OAIC, > University of Maryland Clinical Nutrition Research Unit, and > Baltimore VA Center Stroke of Excellence-- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic
jim holtman
2007-Mar-06 20:25 UTC
[R] Recalling and printing multiple graphs. Is there something in the HISTORY menu that will help?
Here is a function that I have used to write the files on my Windows
machine. I put this function call after each graph that I produce and it
will write out a new file and tell me what the file name is. I can then go
back and copy the files into a document or a PowerPoint presentation.
f.plot <- local({
# PlotNumber is 'local' to the function
PlotNumber <- 1 # initialize the plot number
function(){ # return the function
myplot <- sprintf("ws.%03d.wmf", PlotNumber)
dev.copy(win.metafile, file=myplot, width=10, height=7)
PlotNumber <<- PlotNumber + 1 # increment for next plot
cat("copied to:", myplot, "\n")
invisible(dev.off()) # close the file
}
})
At the end of each plotting sequence, just call "f.plot()" to save the
image.
On 3/6/07, John Sorkin <jsorkin@grecc.umaryland.edu>
wrote:>
> I have written an R function that produces multiple graphs. I use
> par(ask=TRUE) to allow for the inspection of each graph before the next
> graph is drawn. I am looking for a way to recall all graphs drawn in an
> R session, and a method that can be used to print all the graphs at one
> time. I know that I could simply print each graph after I inspect the
> graph, but this gets tiresome if one's function produces tens of
graphs.
> I suspect that if I knew more about the history menu (which currently
> has an entry RECORDING) I could get the graphs to be replayed and
> printed, but alas I have not been able to find instructions for using
> the HISTORY menu. Please take pity on my when you let me know that some
> easy search or command could get me the information I needed. I have
> looked, but clearly in the wrong places.
> John
>
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC,
> University of Maryland School of Medicine Claude D. Pepper OAIC,
> University of Maryland Clinical Nutrition Research Unit, and
> Baltimore VA Center Stroke of Excellence
>
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
>
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> jsorkin@grecc.umaryland.edu
> Confidentiality Statement:
> This email message, including any attachments, is for the so...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]
John Sorkin
2007-Mar-06 21:35 UTC
[R] Recalling and printing multiple graphs. Is there something in the HISTORY menu that will help?
I am re-sending this Email message as it does not appear to have been received my the R mail list Daemon. My apologies of you receive two copies of this message. If you do, it will mean that the first message finally made it through cyberspace to the list server. I have written an R function that produces multiple graphs. I use par(ask=TRUE) to allow for the inspection of each graph before the next graph is drawn. I am looking for a way to recall all graphs drawn in an R session, and a method that can be used to print all the graphs at one time. I know that I could simply print each graph after I inspect the graph, but this gets tiresome if one's function produces tens of graphs. I suspect that if I knew more about the history menu (which currently has an entry RECORDING) I could get the graphs to be replayed and printed, but alas I have not been able to find instructions for using the HISTORY menu. Please take pity on my when you let me know that some easy search or command could get me the information I needed. I have looked, but clearly in the wrong places. John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) jsorkin@grecc.umaryland.edu Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. [[alternative HTML version deleted]]
Mike Prager
2007-Mar-06 22:04 UTC
[R] Recalling and printing multiple graphs. Is there something in the HISTORY menu that will help?
"John Sorkin" <jsorkin at grecc.umaryland.edu> wrote:> I have written an R function that produces multiple graphs. I use > par(ask=TRUE) to allow for the inspection of each graph before the next > graph is drawn. I am looking for a way to recall all graphs drawn in an > R session, and a method that can be used to print all the graphs at one > time. I know that I could simply print each graph after I inspect the > graph, but this gets tiresome if one's function produces tens of graphs. > I suspect that if I knew more about the history menu (which currently > has an entry RECORDING) I could get the graphs to be replayed and > printed, but alas I have not been able to find instructions for using > the HISTORY menu. Please take pity on my when you let me know that some > easy search or command could get me the information I needed. I have > looked, but clearly in the wrong places. > > John Sorkin M.D., Ph.D.I assume you are on Windows (please give OS and R version in future help requests). The code I use before starting such functions is graphics.off() windows(record=TRUE) .SavedPlots <- NULL which closes existing graphics devices, opens a windows device with recording on, and deletes any existing graphics history. You can go through the history with PageUp and PageDown keys. Within your function, you can call savePlot (q.v.) to save each plot to a file just after it is generated. HTH -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement.