Karl Knoblick
2004-Jan-17 14:58 UTC
[R] Multiple groupedData plots in a postscript file using a loop
Hallo! I want to plot multiple grouped data in a postscript file using a loop. As I use a loop no plot (or just one empty plot) is generated. Here an example: library(nlme) data(Loblolly) # example data from nlme postscript("PSFile.ps") for (i in 1:1) # just as example { plot(Loblolly) } dev.off() Result: Just an empty PSFile.ps. (Withoput the loop it works. May anybody help? Karl __________________________________________________________________
Uwe Ligges
2004-Jan-17 15:20 UTC
[R] Multiple groupedData plots in a postscript file using a loop
Karl Knoblick wrote:> Hallo! > > I want to plot multiple grouped data in a postscript > file using a loop. As I use a loop no plot (or just > one empty plot) is generated. Here an example: > > library(nlme) > data(Loblolly) # example data from nlme > postscript("PSFile.ps") > for (i in 1:1) # just as example > { > plot(Loblolly) > } > dev.off()Note that this is a lattice plot: class(Loblolly) [1] "nfnGroupedData" "nfGroupedData" "groupedData" "data.frame" Thus, the method plot.nfnGroupedData() producing a lattice plot is called by the generic plot(). So, you don't want to start postscript(), but trellis.device("postscript", file = "PSFile.ps") plot(Loblolly) dev.off() Uwe Ligges> Result: Just an empty PSFile.ps. > (Withoput the loop it works. > > May anybody help? > > Karl > > > __________________________________________________________________ > > > ______________________________________________ > 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
Deepayan Sarkar
2004-Jan-17 15:32 UTC
[R] Multiple groupedData plots in a postscript file using a loop
On Saturday 17 January 2004 08:58, Karl Knoblick wrote:> Hallo! > > I want to plot multiple grouped data in a postscript > file using a loop. As I use a loop no plot (or just > one empty plot) is generated. Here an example: > > library(nlme) > data(Loblolly) # example data from nlme > postscript("PSFile.ps") > for (i in 1:1) # just as example > { > plot(Loblolly)replace this line with print(plot(Loblolly)) (plot(Loblolly) produces a ``trellis'' object, which needs to be 'print'-ed for anything to be actually plotted. Inside a loop (or a function), this does not happen unless you call print() explicitly)> } > dev.off() > > Result: Just an empty PSFile.ps. > (Withoput the loop it works. > > May anybody help? > > Karl
On Sat, 17 Jan 2004, Karl Knoblick wrote:> My problem was solved by using > trellis.device(win.metafile,file="Loblolly.wmf", > color=F) > instead of win.metafile("Loblolly.wmf"). > (other answers helped also) > > (What I found for getting similiar plots as postscript > was color=F in the trellis.device(...) command) > > Thanks to all! > Karl. > > BTW win.metafile("Loblolly.wmf") does not work for me > with the following versions I updated recently:> R version 1.8.0, 2003-10-08But, the current version is R 1.8.1 and it *does* work in a current version of R (1.8.1 or R-patched or R-devel). -- Brian D. Ripley, ripley at stats.ox.ac.uk 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