Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RStudio doesn't save picture

Tags:

r

rstudio

I'm trying to save a plot zoom I got from using R.

My Rstudio has the option of saving that plot, but it doesn't seem to be working. There's no error message. I go through everything as normal, and then the pic never shows up in the file that it's supposed to. I've tried open the picture, and the save in the default directory, but it still doesn't show up...

Any help would be appreciated.

like image 739
An old man in the sea. Avatar asked Jun 14 '16 11:06

An old man in the sea.


2 Answers

I can confirm this behavior in the latest release of RStudio (v. 0.99.902). A zoomed plot cannot be saved using the menus of RStudio, only the small image in the preview panel is saved with the "Export" pull-down menu. A right-click on the zoomed image, selecting "Save Image" does not work. There is no error message but nothing happens after the output directory and file name is selected and the "Save" button is clicked. I assume it's a bug. FWIW, I'm using ubuntu 16.04.

A quick workaround is to take a screenshot of the window containing the zoomed figure. There are specific OS-dependent keyboard combinations for this, like Alt+Print. Then one can use any image editor to crop the image and remove the window frame.

Other useful options have been posted as answers here, but what I've seen so far is unrelated to RStudio.

like image 161
RHertel Avatar answered Oct 31 '22 21:10

RHertel


You can produce pictures automatically:

pdf("test.pdf")
plot(1, main = "my test PDF")
dev.off()

You can replace pdf("test.pdf") by png("test.png") or other formats of your choice.

like image 1
Qaswed Avatar answered Oct 31 '22 19:10

Qaswed