Skip to content
Prev 316387 / 398503 Next

remove margin between plot and axis

On 13-01-29 7:51 AM, e-letter wrote:
That's probably not doing what you think it does because you used a 
colon instead of a comma.
The parameter "mai" matches "main", so this gives you a funny 3 line 
title.  To set the margins you should probably use "mar" (measured in 
lines) rather than "mai" (measured in inches), and you should give 
values for all 4.  You should also do it with par().  For example,

save <- par(mar=c(0,1,1,0))
plot(test, type='h')
par(save)

It looks terrible (size zero margins don't work well), but fiddling with 
the "mar" numbers should get you what you want.

However, I don't think the margins are what you want.
This isn't a style that's automatically supported within R, but you can 
fake it with a little work.  Use the 'i' style, but set the upper y 
limit above the data.  For example,

yrange <- range(test)
ylim <- yrange[1] + c(0, 1.04*diff(yrange))
plot(test, type='h', yaxs='i', ylim=ylim)

Duncan Murdoch