Data visualization in R: Margins

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(mfrow=c(1,3))
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‘)

 

R17_a

With par(mar=c(…)) you define the margins in number of lines. If you want to specify margins in inches, use par(mai=c(…)).

Werbung
Dieser Beitrag wurde unter R veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit deinem WordPress.com-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s