Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write a plot on the screen to a file?

Tags:

plot

r

In R, if I have already create a plot on the screen, is there a way to write it to a file, without rerun the plotting code again?

Is the quality same as plotting to a file directly? (e.g. when saved to pdf, can get copiable text and scalable showing of the plot)

Thanks!

like image 681
Tim Avatar asked Feb 13 '23 01:02

Tim


1 Answers

Yes, use dev2bitmap

plot(1:10)
dev2bitmap("test.png")

EDIT: Note that you need GhostScript installed. The above code ran fine on my machine (OSX 10.9.2) with 0 tinkering, and I'm pretty sure I never installed GS myself ... but it may have been installed with a larger package, etc, so YMMV.

like image 125
rbatt Avatar answered Feb 15 '23 14:02

rbatt