Reputation: 510
I'm interesting in adjusting margins for R plots. I use R Studio on MacOS, run on a 2013 intel CPU Macbook pro.
Here is the data I used for generating the plot:
spins <- runif(50, min = 0, max = 50)
Here is the code I used to generate the plot:
hist(spins)
Here is the results of the console:
> hist(spins)
Error in plot.new() : figure margins too large
Here are my questions:
Upvotes: 3
Views: 8449
Reputation: 49640
The par
function can be used to see the size of current margins and to set margin sizes (plus a whole bunch of other things).
Running par(c("mar", "mai"))
will report the current margins (starting at bottom and going clockwise) in lines of text (mar
) and inches (mai
).
You can then set the margins using code like: par(mar=c(2,2,2,0))
or par(mai=rep(0.4, 4))
.
But the problem is probably that you have made the plots pane in RStudio too small in at least one dimension, so when the hist
function tries to create the plot there is not enough room for the plot and margin information. Try dragging the appropriate dividers within RStudio to make the plot panel larger then try your code again. Another option is to run the command dev.new()
which will open a new window for the plots (using the default for your OS) and by default send the plot to that new window instead of the plot pane in RStudio.
Upvotes: 7