Hello R-help, I'm trying to make a fairly simple plot axis that goes something like this: plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6) ...but as you can see, the labels are not close enough to the y-axis (where I want them... to save space for publication). Can anybody help me figure out how to move these labels over the the right a bit? Thanks, -D
David Winsemius
2011-Jan-13 04:42 UTC
[R] Rotated, Right-Justified Labels for Shortened Tick Marks
On Jan 12, 2011, at 7:59 PM, dms wrote:> Hello R-help, > > I'm trying to make a fairly simple plot axis that goes something like > this: > > plot(-10:10,-10:10, yaxt='n') > axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6) > > ...but as you can see, the labels are not close enough to the y-axis > (where I want them... to save space for publication).It's not clear what you mean by "labels" but if it is the numbers next to the ticks then you have already found the parameter needed, hadj. plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=0, tck=-.01, cex.axis=.6)> > Can anybody help me figure out how to move these labels over the the > right a bit? > > Thanks,David Winsemius, MD West Hartford, CT
Jim Lemon
2011-Jan-13 06:53 UTC
[R] Rotated, Right-Justified Labels for Shortened Tick Marks
On 01/13/2011 11:59 AM, dms wrote:> Hello R-help, > > I'm trying to make a fairly simple plot axis that goes something like > this: > > plot(-10:10,-10:10, yaxt='n') > axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6) > > ...but as you can see, the labels are not close enough to the y-axis > (where I want them... to save space for publication). > > Can anybody help me figure out how to move these labels over the the > right a bit? >Hi D, Try this: plot(-10:10,-10:10, yaxt='n') axis(side=2,at=seq(-10,10,by=5),labels=rep("",5),tck=-.01) par(cex=0.6) mtext(seq(-10,10,by=5),at=seq(-10,10,by=5),side=2,line=0.3,cex=0.6) par(cex=1) Jim
Dave Schruth
2011-Jan-13 21:55 UTC
[R] Rotated, Right-Justified Labels for Shortened Tick Marks
mgp[2]! That's exactly what I wanted! Thank you Vicki! #final solution: plot(-10:10,-10:10, yaxt='n') axis(side=2, las=1, hadj=1, tck=-.01, cex.axis=.6, mgp=c(3,.5,0)) On Thu, Jan 13, 2011 at 8:29 AM, Lancaster, Vicki <Vicki.Lancaster at fda.hhs.gov> wrote:> Try using mgp: > > From help(par) > > mgp > The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(3, 1, 0). > > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Dave Schruth > Sent: Thursday, January 13, 2011 11:01 AM > To: Jim Lemon > Cc: r-help at r-project.org > Subject: Re: [R] Rotated, Right-Justified Labels for Shortened Tick Marks > > Jim, > > This was the solution I was hoping to avoid having to implement... but > thank you it does what I was looking for visually (except for the > las=1 rotation). ? Is there no other parameter *within* axis that I > could adjust? ?If not, it seems like axis could be rewritten to have > the axis tick label positions move in concert with the shortening tick > marks... > > -D > > On Wed, Jan 12, 2011 at 10:53 PM, Jim Lemon <jim at bitwrit.com.au> wrote: >> On 01/13/2011 11:59 AM, dms wrote: >>> >>> Hello R-help, >>> >>> I'm trying to make a fairly simple plot axis that goes something like >>> this: >>> >>> plot(-10:10,-10:10, yaxt='n') >>> axis(side=2, las=1, hadj=1, ?tck=-.01, cex.axis=.6) >>> >>> ...but as you can see, the labels are not close enough to the y-axis >>> (where I want them... to save space for publication). >>> >>> Can anybody help me figure out how to move these labels over the the >>> right a bit? >>> >> Hi D, >> Try this: >> >> plot(-10:10,-10:10, yaxt='n') >> axis(side=2,at=seq(-10,10,by=5),labels=rep("",5),tck=-.01) >> par(cex=0.6) >> mtext(seq(-10,10,by=5),at=seq(-10,10,by=5),side=2,line=0.3,cex=0.6) >> par(cex=1) >> >> Jim > > ______________________________________________ > 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. >