RStudio stuck when loading any plot


I am encountering an issue when trying to plot anything in RStudio, whether with the basic plot function or with ggplot2.

When I run the code (even for the simplest plot), RStudio seems to get stuck, with the little "stop" sign of the console never disappearing, and crashes after a while.

Any idea why ?

I am working on macOS Monterey 12.3.1 and with the latest version of RStudio. I had the same issue with previous versions of RStudio.

Thanks for your help !

Not a clue.

These work for me

ht  <- c(145, 167, 176, 123, 150)
wt  <- c(51,63,64, 40, 55 )

plot(ht, wt)


dat1  <- data.frame(ht, wt)

ggplot(dat1, aes(ht, wt, fill = "red"))

Perhaps you could post the output of

1 Like

Thank you for your answer !
Using your code, RStudio got stuck again when running the line


Here is the output from sessionInfo :

@YohanCowboy this might be oversimplified on my end but have you tried clearing your graphics device with

@ jonesey441

Brillant suggustion!

@ YohanCowboy
Building on jonesey441's suggestian is there a chance that you are automatically loading a .Rdata file when starting RStudio?

I would reccomend going to Tools > Globas Options > Basic and setting the Workspace options to Never.

Thanks for your help !
Unfortunately, I followed your suggestions and the problem is still there.

Thanks for your help !
I have tried, and I get this error message in return :

@YohanCowboy ,

Let's try to isolate the issue by passing the plot to a variable

plot <- plot(height, weight)

See if it will create the variable.

Also I noticed in the Plots pane that the toolbar buttons are illuminated and clickable, which only happens when there is a plot in the pane. What happens if you select the broom icon to clear the plot variables there?

The problem is the same when trying to create the variable, the "Stop" sign just stays there and RStudio seems stuck.

This time, the toolbar buttons in the Plots pane were not clickable, but in an earlier try they were. When I tried the broom, it said "Clearing..." at the top of RStudio but without finishing the task.

Thanks again for your time and help !

@YohanCowboy ok that tells me that the issue is likely in the plot function itself, since passing it to a variable would skip displaying the plot.

Try running plot in debug mode with

plot(height, weight)

Thanks for the suggestion.

When I run the code, it opens a new tab :

Do you know what I should do next ?

Thanks again !

Update ! I seem to have solved the issue, in the Preferences. In the "Graphics" tab from the "General" menu, I switched 'Backend' from (Default) to Cairo, and now it works ! I am so relieved :smiley:

Thanks for taking the time to try and help me !

1 Like


If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.