I've recently developed a problem with the plot pane in RStudio ver. 1.4.1103 (R ver. 4.1.0) running on a Windows 10 virtual machine. I have a script that generates four plots, each with about 7,500 data points. The plots usually work correctly if I run the whole script from start to finish (takes about four minutes). But I often want to fine-tune the appearance of the graphs, so after the script finishes, I make some adjustments to the ggplot2 options, I select a block of code that includes the ggplot2 function, and I execute just that one block. In that case, the plots often come out missing components, like annotations, axes, and the box around the plot. Interestingly, even if the plot looks wrong in the plot pane, it looks correct if I click on the zoom icon, and it's also correct if I save the plot as a PNG file. This is a fairly new problem.
Here's an example of what a faulty plot looks like in the plot pane:
https://ibb.co/7rCGZG2
It's supposed to have axes and a box around the graph. Sometimes, the annotations are missing (though not in this particular example).
The problem is sporadic, and I don't have a reproducible example.
Here's what I've tried to solve the problem:
- Increasing the size of the plot pane in the RStudio IDE
- Running
dev.off() before plotting
- Running
gc() before plotting
- Updating to the latest version of R
- Updating all the packages
None of this helps. I'm willing to try reinstalling RStudio, if necessary.
Thanks for any help.