23

Whenever I plot any plot in RStudio, I get a new device window that pops up. This was not always the case. I must have changed some settings. How do I change the settings back to have plots go to the RStudio plot window?

I have explored the dev.off() and other dev functions without success. For example:

# Clear workspace
rm(list=ls())

# create data
set.seed(1)
x <- rnorm(100, 0, 1)
y <- rnorm(100, 3, 1)

plot(x,y)

produces the popped up window in the screenshotted image: enter image description here

I want the device to stay in the RStudio plot window in the lower righthand corner. Does anyone have any help? I saw a similar question here that claims that an update will fix the issue. I updated within the last week. When I use sessionInfo() I am running R version 3.3.2, what I believe to be the latest version of R.

Phil
  • 578
  • 3
  • 7
  • 17
  • Do you have "plots" selected in the bottom right hand corner of the pop up from `View > panes > pane layout ...`? – lmo Nov 18 '16 at 16:28
  • @lmo I must admit that I do not see where you are referencing. I apologize if I cannot find something seemingly obvious. The pop-up looks like the image above. However, if I go to the Pane Layout, as in `Tools > Global Options > Pane Layout`, "Plots" is checked. – Phil Nov 18 '16 at 16:45
  • OK. They both get you to the same place... So that's not it. – lmo Nov 18 '16 at 16:48
  • What is the output of `getOption("device")`? It should return `RStudioGD` if the RStudio graphics device is in use. – Kevin Ushey Nov 18 '16 at 21:12
  • What happens if you first call the following function `close_all_graph <- function() {if (dev.cur() != 1) {dev.off(which = dev.cur())}; graphics.off(); return(NULL)}`? – Christoph Nov 22 '16 at 16:40
  • @KevinUshey thanks for the help. It returns what I believe to be the device function with all its arguments. – Phil Nov 22 '16 at 18:36
  • @Christoph The `close_all_graph` function returns `NULL` – Phil Nov 22 '16 at 18:38
  • That it what it should do. But the window still opens? – Christoph Nov 23 '16 at 07:41
  • @Christoph Yeah. It still opens. I think I'm going to try another update and/or reinstall because this started happening around my last update. I'll update if that works, but I'm completely lost. – Phil Nov 23 '16 at 14:18
  • Really strange... Hopefully reinstallation helps! – Christoph Nov 23 '16 at 14:21
  • Same issue here, it's really wierd. Happened after an update to R 3.3.2. – puslet88 Jan 17 '17 at 08:40
  • possibly found a solution: Warning message: R graphics engine version 11 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed. – puslet88 Jan 17 '17 at 08:45
  • 1
    I have 1.1.423 and have had it for a while and this just started happening today. It's never happened before. I didn't change any settings in R or RStudio. It's extremely annoying because I can't run my next line of code without clicking back in the code window. – GeoffDS May 04 '18 at 15:39
  • Or, perhaps it updated automatically without my knowledge and the new version is causing the issue. – GeoffDS May 04 '18 at 15:45

5 Answers5

5

I know that this has been answered but the problem can arise in multiple ways. My issue had been much simpler. The plots were not showing up in the Rstudio plot pane simply because the default null GD was turned off via dev.off(). I'm running Rstudio Version 1.1.442 with R Version R-3.4.4

I ran dev.off() a few times until all windows including hidden ones were closed and I received the following response in the console window.

null device 1

I then ran this and the plot appeared in the RStudio plot pane

dev.new()
plot(mtcars$mpg~mtcars$disp)
George
  • 1,343
  • 2
  • 12
  • 17
  • This helped (I accidentaly initialized multiple PDF writting devices with "pdf" command and did not dev.off them all). Isn't here dev.new() unecessary? The null device can not be shutdown and will be used after all other devices were shut down. – al-ash Dec 12 '19 at 09:12
3

For others who like me may still encounter this issue:

This is probably caused by an R update to 3.3.2 and is fixed by installing a newer version of RStudio. In my case 1.0.136 did the trick.

puslet88
  • 1,288
  • 15
  • 25
  • 1
    I have 1.0.136 and still facing the same issue. – Dhiraj Mar 16 '17 at 09:41
  • 1
    Still broken for me with RStudio 1.0.136 / R 3.3.3. (Was also broken with RStudio 1.0.136 / R 3.2.3.) – Pont Mar 27 '17 at 09:23
  • 1
    I found the problem after updating to R 3.4.3 with RStudio 0.98.501. When launching RStudio I received the warning message "R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed". The problem was solved after updating to 1.1.383. – lodebari Jan 12 '18 at 12:58
  • I have 1.1.456 and it has this issue. – EngrStudent Mar 11 '22 at 04:34
1

I solved this problem by updating RStudio (Help--> check for updates). The new version of RStudio I updated to is Version 1.1.383 and this problem was fixed. Currently I have version 3.4.3 for R.

Amazonian
  • 391
  • 2
  • 8
  • 22
0

Go to R studio menu bar and Tools->Global options->R Mark down In that phase select "window" from that list in the "show output preview in:" then apply

0

As for July 2023 I got the same problem and only after updating RStudio I was able to plot in the Plot Window. All other solutions I have found in stackoverflow haven't worked.