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:
Thanks for the suggestion, Martin, but installing the preview version of RStudio didn't solve the problem. In fact, it introduced a new problem. Now there is some weirdness with the console window. I have a cat('\f') statement at the beginning of my script. In previous versions of RStudio, this statement acted to clear the console. It now clears the console, but it also prevents any subsequent output from appearing. If I remove the cat('\f') statement, I do get output, but the console window doesn't scroll properly. The output runs off the bottom of the window, and the only way to see it is to use the mouse to manually move the scrollbar down. This problem never occurred with previous versions of RStudio.
Update: The issue with cat('\f') and the scrolling issue were both fixed by un-checking Tools -> Global Options -> Console -> Limit visible console output.
I figured out the problem with the missing components in the ggplot2() graphs. I had one data point that lay outside the boundaries of the graph. That data point would generate a warning message from ggplot, but I just ignored the message. When troubleshooting this problem, I tried dropping that one offending data point from the dataframe, and I found that I no longer had issues with missing axes, notations, etc.
What still puzzles me about this issue is that it wasn't consistent. Sometimes the graphs looked right, and sometimes they had missing components.