[R] How do I save a figure with postcript()

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jan 6 08:34:58 CET 2002


On Sun, 6 Jan 2002 hzi at uol.com.br wrote:

> Hi-
>
> 	I have this small data set (this is from Glantz`s
> Biostatistics textbook, from the Hebbel et al. paper):
>
> 0 0 0 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 5 5 5 5 6 7 9 10 11
>
> 	I wanted to produce a histogram+density plot, so I did this
> (BTW, I got this from the r-help archives, but it would be nice if
> someone included it some of the documents), after scanning the data
> set:

(Eh?  We try to put accurate information in the docs.  This doe snot look
right, and it is certainly incomplete.)

> histo <- hist(hebbel, xlim = range(dest$x), xlab = "x", ylab = "density", freq=FALSE)
> > dens <- lines(dest,lty=2)

hebbel <- scan()
1: 0 0 0 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 5 5 5 5 6 7 9 10 11
34:
Read 33 items
hist(hebbel, prob = T, nclass = 11)
rug(jitter(hebbel))
lines(density(hebbel, bw="SJ"))

would do a reasonable job, but as this dataset is clearly not a continuous
observation, it is not clear that a density plot is appropriate.


> 	Then, I went on to save it as a .ps and an .eps file. As I
> understood in the R-intro.pdf:
>
> > postscript("/home/synthespian/r_graphics_test_plot.ps", horizontal=FALSE, height=5, pointsize=10)
> > postscript("/home/synthespian/r_graphics_test_plot.eps", horizontal=FALSE, height=5, pointsize=10)

You need to set width too.

> 	But this produced a file with 0 Kb (as loaded with xv)!
> 	And what are some good parameters - height and pointsize?
> 	Obviously, this is the way to go about it.
> 	How do I do it?

You need to plot on the device (so do this first), or use dev.copy2eps to
make a copy.

There is no difference in R between .ps and .eps plots.

> 	TIA,
> 	Regs,
> 	HL
>
> PS: BTW, xlisp-stat has this _nice_ feature which is when you produce
> the graphic, you can just click on a widget so save it, change colors,
> etc. I wish this were present on R.

It is on versions of R with a GUI: on the File menu under Windows, and I
think also on the GNOME GUI.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list