Postscript graphics from R

· GNU-R, Graphics
Authors

Graphics made in R are best saved as postscript files if the files are to be used for printing. This can be done by wrapping your commands (for example, plot) in a postscript device, or by printing the plot to postscript after the plot has been created.

Method 1.

postscript(“filename”,width=x,height=y)

plot commands

dev.off()

 

Method 2.

Plot commands #these would, by default, display the plot on the screen

dev.copy2eps(file=<filename>,width=x,height=y) #also see ?dev.print

Note that the postscript files created by R do not have a preview attached with them. So that, when you insert them in an MS-word/Openoffice file, you just see a bounding box and not the image itself. Of course, it prints the image all right.

Your friends who are not used to postscript files may be uncomfortable with this. If you want to insert a preview image so that they can see the image on the screen as well, use epstool on the linux command line to add a preview to the postscript file.

 

Technorati:

%d bloggers like this: