RStudioGD shouldn't error when the plot window is shrunk



Often, to maximize space for code (console + terminal), I shrink the plotting window as seen here:

Whenever I need to plot something, I just pop out the plotting window to preview my beautiful data in its full glory.

However, all too often, this is interrupted by having shrunk the plotting area – an error is returned since there’s no room for the plot. Almost always this is the “figure margins too large” error observed here (actually I got a warning since I shrunk the window after it had already plotted), but I’ve also seen it in the form of a warning about “zero-length-arrows” from arrows (since in the shrunk window, it’s easy to put in data that leads to arrows less than 1/100" in width, the threshold obeyed there).

When presented with such an error, there are two options, both of which are none too convenient:

  1. Don’t use RStudioGD. Just pipe the preview plot to pdf/png/whatever external device, and open the file. This defeats the purpose of having a plotting window in RStudio.
  2. Unshrink the plot window. This is annoying because 1) I have to shrink my code as a tradeoff and 2) it’s sometimes an iterative process, re-plotting as I balloon the window little by little – how much space is too little?

I see a few potential solutions:

  1. Don’t render the plot if RStudio recognizes its graphics device is too small – display a warning in the plotting window (much akin to the one seen above) asserting that the window must be expanded or popped out before rendering will happen.
  2. Allow an option to always open a new window for newly generated plots (pre-popping the window); this is essentially a version of the first workaround from above, but doesn’t require creating temporary/ephemeral plot files.


Do you think it would make sense for RStudio to automatically expand the plot window if it discovered that it were too small in some dimension, so that plotting could succeed?


I think if that’s possible, why not prompt the user first – “Do you want to balloon the plot frame, or do you want to pop out the plot?”

Could add a global option if users would like to set a default behavior.