Hi, List, I used the following codes to generate ps plots but foo.ps contains nothing. Would someone please point out what is wrong with my codes? Thanks a million! postscript('foo.ps') par(mfrow=c(2,1)) par(mfg=c(1,1)) hist(rnorm(100),col='blue') par(mfrow=c(2,2)) par(mfg=c(2,1)) hist(rnorm(50),col='blue') par(mfg=c(2,2)) hist(rnorm(60),col='blue') dev.off() Best, Auston Auston Wei Statistical Analyst Department of Biostatistics and Applied Mathematics The University of Texas MD Anderson Cancer Center Tel: 713-563-4281 Email: wwei@mdanderson.org [[alternative HTML version deleted]]
On Tue, 2005-09-20 at 18:30 -0500, WWei at mdanderson.org wrote:> Hi, List, > > I used the following codes to generate ps plots but foo.ps contains > nothing. Would someone please point out what is wrong with my codes? > Thanks a million! > > postscript('foo.ps') > par(mfrow=c(2,1)) > par(mfg=c(1,1)) > hist(rnorm(100),col='blue') > par(mfrow=c(2,2)) > par(mfg=c(2,1)) > hist(rnorm(50),col='blue') > par(mfg=c(2,2)) > hist(rnorm(60),col='blue') > dev.off() > > Best, > > AustonIt sort of works here using: Version 2.1.1 Patched (2005-09-14) on FC4 in that the graphic is drawn, but the output device dimensions are not appropriate for the plot and the plot is rotated relative to the page. The page is landscape orientation and the plot is cuttoff on the bottom (actually right axis) as a result of the rotation. Your e-mail headers suggest that you are on Windows and you do not specify which version of R you are running, so there may be some differences in what you see on your system resulting in problematic output. Try this. I am using layout() here and note that your code above can be replaced by: postscript("foo.ps", width = 6, height = 6) layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE)) hist(rnorm(100),col='blue') hist(rnorm(50),col='blue') hist(rnorm(60),col='blue') dev.off() Note that I am specifying height and width dimensions for the postscript output. See if that changes anything on your system. You can of course modify the dimension arguments as you may require. Also note that if you want to create an EPS output file, you would need something like: postscript("foo.ps", width = 6, height = 6, horizontal = FALSE, onefile = FALSE, paper = "special") See the Details section of ?postscript and also ?layout. HTH, Marc Schwartz
Marc, Thank you very much for your help! Your codes worked perfectly fine here. I am using R 2.0.1 on Red Hat 9, sorry for not specifying it in my original post. I didn't know we could use layout to plot, it is much easier than par(mfg). Thanks a lot! Best, Auston Marc Schwartz <MSchwartz@mn.rr.com> Sent by: r-help-bounces@stat.math.ethz.ch 09/20/2005 07:20 PM Please respond to MSchwartz To: WWei@mdanderson.org cc: r-help@stat.math.ethz.ch Subject: Re: [R] why this postscript didn't work? On Tue, 2005-09-20 at 18:30 -0500, WWei@mdanderson.org wrote:> Hi, List, > > I used the following codes to generate ps plots but foo.ps contains > nothing. Would someone please point out what is wrong with my codes? > Thanks a million! > > postscript('foo.ps') > par(mfrow=c(2,1)) > par(mfg=c(1,1)) > hist(rnorm(100),col='blue') > par(mfrow=c(2,2)) > par(mfg=c(2,1)) > hist(rnorm(50),col='blue') > par(mfg=c(2,2)) > hist(rnorm(60),col='blue') > dev.off() > > Best, > > AustonIt sort of works here using: Version 2.1.1 Patched (2005-09-14) on FC4 in that the graphic is drawn, but the output device dimensions are not appropriate for the plot and the plot is rotated relative to the page. The page is landscape orientation and the plot is cuttoff on the bottom (actually right axis) as a result of the rotation. Your e-mail headers suggest that you are on Windows and you do not specify which version of R you are running, so there may be some differences in what you see on your system resulting in problematic output. Try this. I am using layout() here and note that your code above can be replaced by: postscript("foo.ps", width = 6, height = 6) layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE)) hist(rnorm(100),col='blue') hist(rnorm(50),col='blue') hist(rnorm(60),col='blue') dev.off() Note that I am specifying height and width dimensions for the postscript output. See if that changes anything on your system. You can of course modify the dimension arguments as you may require. Also note that if you want to create an EPS output file, you would need something like: postscript("foo.ps", width = 6, height = 6, horizontal = FALSE, onefile = FALSE, paper = "special") See the Details section of ?postscript and also ?layout. HTH, Marc Schwartz ______________________________________________ R-help@stat.math.ethz.ch mailing list stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! R-project.org/posting-guide.html [[alternative HTML version deleted]]