[R] Creating images without X11

(Ted Harding) Ted.Harding at manchester.ac.uk
Sat Mar 13 23:16:19 CET 2010


On 13-Mar-10 16:27:05, Jillian E Kozyra wrote:
> Dear Colleagues,
> 
> We are attempting to create trees using R with our Ruby on Rails
> application. However, we are running into a problem involving the
> creation of the graphic. We would like them to be in either jpg or png
> format so that users can save, but due to a lack of control over our
> sever we are unable to start X11 server. Is there a way to create
> these images without using X11 server?
> 
> Thanks,
> JIllian
> -- 
> 917-434-7511
> http://www.jilliankozyra.com

Provided you trust your code to produce correctly the graphic you
want (i.e. you do not need to inspect the graphic on-screen to
verify that it is correct), then there should be no problem.
As a test, I just switched (Ctrl-Alt-F1) to a text console in
Linux, and then executed

  R --no-save
  png("MyPNG.png")
  plot(rnorm(10),rnorm(10))
  dev.off()

Then I killed R, switched back (Ctrl-Alt-F7) to the graphical
desktop, and then found the file MyPNG.png safe and well which,
when displayed, was just what it should be.

Summary: So long as you do not try to plot graphics to screen,
and use the png() or jpg() device (as above), then the graphic
will be written to file without needing X11. However, you will
not, of course, be able to see them on screen. If you just did
the plot() command without encapsulating it in a device to
write files as above, then nothing would happen.

It is possible to convert a graphics file into "ASCII Art",
and then you could see a (very) coarse approximation to your
graphic on-screen in a console terminal. However, I'm not
going to make any recommendations on how to do that!

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Mar-10                                       Time: 22:16:16
------------------------------ XFMail ------------------------------



More information about the R-help mailing list