I cannot find information on this anywhere. I know how to set them but want to know the defaults (top, right, bottom, and left) so its less of a guessing game when setting margins for a plot.
To visualize how R creates plot margins, look at margin Figure 11.20. You can adjust the size of the margins by specifying a margin parameter using the syntax par(mar = c(bottom, left, top, right)) , where the arguments bottom , left … are the size of the margins. The default value for mar is c(5.1, 4.1, 4.1, 2.1).
In order to modify the plot margins set the margin function inside the plot. margin component of the theme function. The margins are measured with points ( "pt" ), but you can use other unit measure in the unit argument, like centimeters.
For plot margins as well as other parameters, the default values are that of theme_grey
:
theme_grey()$plot.margin [1] 5.5pt 5.5pt 5.5pt 5.5pt
However, the default theme might change in the future, and you can set a different one (with theme_set()
) so a more robust way would be to use theme_get()
which returns the current theme (@r2evans comment)
theme_get()$plot.margin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With