Skip to content

remove margin between plot and axis

6 messages · Pascal Oettli, e-letter, Ivan Calandra +2 more

#
Readers,

Am trying to plot a graph with type 'h' and want to remove the white
space between the plot lines and the x axis. The help section 'par'
suggests that the option 'mai' controls this feature, but the syntax

plot(...mai=c(0,1,1))

is ineffective

Any advice please?

--
r2151
#
Hi,

Please provide a reproducible example.

Regards,
Pascal

Le 29/01/2013 19:40, e-letter a ?crit :
#
On 29/01/2013, Pascal Oettli <kridox at ymail.com> wrote:
test<-seq(10:50)
plot(test,type='h',mai=c(0,1,1))

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
#
Not sure wat you're trying to do... Can you explain more what you expect 
your plot to look like?
What about plot(..., frame=FALSE)?

Ivan

--
Ivan CALANDRA
Universit? de Bourgogne
UMR CNRS/uB 6282 Biog?osciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 29/01/13 13:51, e-letter a ?crit :
#
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
#
Something like 
  plot(test,type='h',yaxs='i', ylim = c(0, 60)) ?  

You would need to figure out what the right values for ylim are.

John Kane
Kingston ON Canada
____________________________________________________________
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!