[R] Things I don't understand about the graphics interface

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Aug 18 08:49:44 CEST 2000

On Thu, 17 Aug 2000, Paul E Johnson wrote:

> Prof Brian D Ripley wrote:
> > 
> > On Thu, 17 Aug 2000, Paul E Johnson wrote:
> > Also, you do seem to be confusing printing to a
> > sheet of paper with producing a plot in a graphics format. The latter just
> > encodes the plot region at the size and shape specified by width and
> > height.  The former places the plot region within the paper region. You
> > seem to be reading into the docs things I think are just not there,
> > not should be.

> I totally agree.  I'm just feeling my way along.  I have to be sure I
> have a workable plan to manage the output before I get too much further
> along.  In the past, I have used Axum to make graphs and I liked it
> pretty well, but now I'm trying to wean myself of the pointing and
> clicking and MS Windows. 
> Maybe you should tell me the best way to attack  my problem. I never
> want to print to a printer, I always want to save the graphs to files
> which can then be imported into word processors or some kind of editor.
> I'm debating whether to try writing with Lyx in order to generate Tex
> output.  In the past, I've used editors like MS word or Applixware
> Words.  I'm starting a project in which I will probably generate 50 or
> 100 figures from start to end, and when the manuscript is finished, I
> don't want to have to rerun all the figures to resize them by one inch
> or something.  My experience is that, if I output a gif that does not
> fit on the page, then I've shot myself in the foot because resizing the
> graph makes all the text in it too small.  I don't think postscript is
> immune to this problem, but you can for sure convince me I'm wrong.  I

It is.  After all, my books on S are done that way, as is much professional
publishing.  If you want to incorporate graphs into other documents (not,
say, a Web site) use a re-scalable vector format, namely postscript, PDF or
(on Windows) W/EMF.  (All of those can contain non-rescalable elements, but
they will not from R device output.  There are also limits to the
scalability, but +/-25% is fine.)

> was considering the tex output from R, but I don't know what to do with
> it after I get it :)  I've not learned how to incorporate them into Lyx,
> but I think that may be a Lyx configuration problem, I'm looking into it
> So, as you can see, I'm not a complete novice, but I don't have a
> definite plan for how to do this manuscript, and I'm open to your
> suggestions.
> > 
> > I think your examples should be using dev.copy, not dev.print.
> > 
> Could you please explain? I have read ?dev.copy over and over again, and
> I don't see what you mean.  I want it copied to a file, not a device. 
> dev.copy has no file= option.

You do want it copied to a device. You do not want the R graphics commands
in internal format on a file, you want them rendered in png or postscript
or .... As the help page says

     Most devices (including all screen devices) have a display list
     which records all of the graphics operations that occur in the
     device. `dev.copy' copies graphics contents by copying the display
     list from one device to another device.

Either use dev.copy2eps which encapsulates all this for you, or modify
it for your purposes.  E.g. to copy to png

    dev.copy(device=png, file="foo", width=500, height=300)

What's difficult about that?

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