Molx Molx - 1 month ago 8
R Question

Why add 0.1 when changing the margins of plots in R?

I've seen this lots of times, and just noticed it's also on the help page of

par
:

The default is c(5, 4, 4, 2) + 0.1


Why is it that the default has this 0.1 addition, and it's also common to see
+ 0.1
when changing
par(mar)
?

When setting
par(mar=c(0, 0, 0, 0) + 0.1)
I thought the idea was to set a minimum margin, but it doesn't make sense for values different than zero.

Answer

I don't know, but S: An Interactive Environment for Data Analysis and Graphics (Becker and Chambers 1984, the first book on S, which is the ancestor of R) gives these defaults (search for xrig) and says (p. 95)

enter image description here

(the appendix clarifies that this actually includes the additional 0.1, but doesn't give any additional explanation). I think that's the best you're going to do. John Chambers is still around; while he hasn't been active on the R-help mailing list since 2004 he continues to contribute to the development list ... even if you bug him, I'm not sure he would remember the rationale for a minor design decision he (or one of his co-authors) made more than 30 years ago ...

My own guess, for whatever that's worth, is that one might expect e.g. 4 lines' worth of material outside the left edge of the plot (e.g. ticks, tick labels, and a two-line axis label), with the 0.1 as "additional margin" so that text isn't exactly hitting the edge.