You may set margins of a plot to adapt its visualization. This could be necessary if you want to change the labeling of a plot, e.g. by adding a legend, additional labels or change the style of axes. Or you may want to use the full space for the data by removing the plot title, axes titles or axes labels.
In such cases you can modify the plot margins with the par function. The default is par(mar=c(5,4,4,2)) which means that there are 5 lines at the bottom, 4 lines on the left, 4 lines in the top and 2 lines on the right.
Here is an example of plots with standard margin, increased margin and decreased margin.
par(mar = c(5,4,4,2))
plot(1,1, main=’default margin‘)
par(mar = c(6,6,6,4))
plot(1,1, main=’increased margin‘)
par(mar = c(2,2,2,1))
plot(1,1, main=’decreased margin‘)
With par(mar=c(…)) you define the margins in number of lines. If you want to specify margins in inches, use par(mai=c(…)).