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
Thanks (Merci) Christophe! that did it --- Christophe Bonenfant <bonenfan at biomserv.univ-lyon1.fr> wrote:> Hi Etienne - consider to use the mtext function: > > > 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="",ylab="",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)) > > mtext("Years", 1, 3.5, cex = 1.7) > # first interger is the axis number, second number > is the distance to > the axis > > mtext("Onset/Withdrawl Date", 2, 4, cex = 1.7) > > see ?mtext > > Christophe > > Etienne a ?crit : > > 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. > > > > >
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)) --- Etienne <etiennesky at yahoo.com> wrote:> 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. >