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

Paul E Johnson pauljohn at ukans.edu
Thu Aug 17 09:14:43 CEST 2000


Using R-1.1.1 on RedHatLinux 6.2.
I've made some progress, succeeded in outputting bitmap, jpeg, and png
files.  Yipee.

I did them with this command:
> dev2bitmap("whatever.bmp",res=300)
> dev.print(png, file="myplot.png", width=480, height=480)
> dev.print(jpeg, file="myplot.jpg", width=480, height=480)
> dev.print(pictex, file="myplot.tex", width=480, height=480)
 
Now here are the things I don't understand about the docs and/or this
interface.  I understand these functions have undergone change...

1. Why is there a separate method dev.copy2eps. To be consistent,
shouldn't we be able to do
> dev.print(eps, ...)
and why does bitmap format have dev2bitmap, rather than
dev.print(bitmap, ...)?

When I tried that once like so:
> dev.print(bitmap, file="myplot.jpg", width=480, height=480)
R churned way, running and writing and never stopping. Then I did it
again, just for fun, and I got:
> dev.print(bitmap, file="myplot.jpg", width=480, height=480)
Error in dev.print(bitmap, file = "myplot.jpg", width = 480, height =
480) :
        can only print from screen device
> 


2. Do png and jpeg usage inherit the paper size, width, and height set
by the postscript() or ps.options().  

3. I see that png() and jpeg() have no "horizontal" option. Is that
because they are being saved in a file, and there is no need to
constrain them to fit in a piece of paper?   

4. Can you explain this?  I did
>example(hist)
and a bunch of histograms flew by really fast.  Then I did
> png(file="test.png")
> example(hist)
> dev.off()
I expected the file "test.png" to have just one figure, I was guessing
the last one that showed on the screen. But instead it was a figure with
4 histograms, arrayed in a 2x2 matrix.  What controlled that?  png() has
no option like onefile=FALSE.

5. I wish there was "maximum aspect-ratio preserving" adjustment for
size.  If I'm looking at a graph on the screen, and I like it, except it
is too big, I'd like to specify a width and have R assume the
corresponding height.  Otherwise, when I try to specify height and
width, R tries to stretch the objects being drawn and it looks like
hell.  It is important to make this adjustment inside R, I think, in
order to keep the figure looking nice and to avoid scaling it in the
Gimp or something. 

6. The commands above suceeded with R-1.1.1 on RedHat 6.2, but with
R-1.1 on RedHat 6.1, I did the same things and the png and jpeg images
were corrupted/unviewable every time.  Is this likely due to different
versions of X or ghostscript?
  
-- 
Paul E. Johnson                       email: pauljohn at ukans.edu
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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