Re: [R] changing the position of the y label (ylab)

From: Stephen Tucker <brown_emu_at_yahoo.com>
Date: Tue, 26 Jun 2007 00:04:56 -0700 (PDT)


If by 'position' you mean the distance from the axes, I think 'mgp' is the argument you are looking for (see ?par)-

You can set this in par(), plot() [which will affect both x and y labels], or title():

par(mar=rep(6,4))
plot(NA,NA,xlim=0:1,ylim=0:1,xlab="X",ylab="") title(ylab="Y2",mgp=c(4,1,0))

if you want to change 'position' parallel to the axis, then you probably have to do
plot(...,xlab="",ylab="")

and set labels using mtext(); playing around with the 'adj' argument.

Btw, you can use '\n' to denote new line: title(ylab="Onset/Withdrawl\nDate",mgp=c(4,1,0))

> How can I change the position of the ylab, after
> enlarging the margins with par(mar=...)?
>
> Here is the relevant code snippet
>
> ----
> par(mar=c(5.1,5.1,4.1,2.1))
>
plot(c(1979,2003),c(40,50),ylim=c(1,73),lab=c(20,10,1),pch=21,col='blue',bg='blue',axes=FALSE,xlab="Years",ylab="Onset/Withdrawl
> Date",font.lab=2)
> box()
> axis(1,las=2)
>
axis(2,las=2,labels=c('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','JAN'),at=seq(from=1,to=73,by=6))
> axis(3,labels=FALSE)
> axis(4,labels=FALSE,at=seq(from=1,to=73,by=6))
> ----
>
> Thanks
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>



R-help_at_stat.math.ethz.ch 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. Received on Tue 26 Jun 2007 - 07:09:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Jun 2007 - 09:32:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.