[R] remove margin between plot and axis
Duncan Murdoch
murdoch.duncan at gmail.com
Tue Jan 29 14:19:29 CET 2013
On 13-01-29 7:51 AM, e-letter wrote:
> On 29/01/2013, Pascal Oettli <kridox at ymail.com> wrote:
>> Hi,
>>
>> Please provide a reproducible example.
>>
>
> test<-seq(10:50)
That's probably not doing what you think it does because you used a
colon instead of a comma.
> plot(test,type='h',mai=c(0,1,1))
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.
>
> Tried
>
> plot(test,type='h',yaxs='i')
>
> but this has the non-wanted effect of removing white space from
> between the highest peak and the upper (top) axis
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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list