[R] why this postscript didn't work?

Marc Schwartz MSchwartz at mn.rr.com
Wed Sep 21 02:20:24 CEST 2005

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,
> Auston

It 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

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))

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.


Marc Schwartz

More information about the R-help mailing list