[R] shifting ticks to left or right

Schreiber, Stefan Stefan.Schreiber at ales.ualberta.ca
Wed Oct 1 22:07:31 CEST 2008


Thank you very much!

That's the way to go!

Cheers,
Stefan


-----Original Message-----
From: Richard.Cotton at hsl.gov.uk [mailto:Richard.Cotton at hsl.gov.uk] 
Sent: Wednesday, October 01, 2008 10:52 AM
To: Schreiber, Stefan
Cc: r-help at r-project.org; r-help-bounces at r-project.org
Subject: Re: [R] shifting ticks to left or right

> Does anybody knows a command to centre the tick mark labels exactly
> between the tick points (right shift)?
> And then to exclude the last tick label on  the right?
> 
> I know one can shift them using the 'hadj' option in par. But I am
> wondering if there is a more convenient command!

A little nasty, but:

plot(1:10, axes=FALSE)
par(tcl=-0.5)
Axis(side=1, at=c(1,5,9), labels=rep("",3))
par(tcl=0)
Axis(side=1, at=c(3,7), labels=c("foo", "bar"))

Regards,
Richie.

Mathematical Sciences Unit
HSL

Schreiber, Stefan wrote:
> Hey list,
>
> Does anybody knows a command to centre the tick mark labels exactly
> between the tick points (right shift)?
> And then to exclude the last tick label on  the right?
>
> I know one can shift them using the 'hadj' option in par. But I am
> wondering if there is a more convenient command!
>
> Thanks a lot!!

Plot the axes twice:  once with ticks and no labels, once with labels 
and no ticks, e.g.

plot(1:10, axes=F)
axis(1, labels=F)
axis(1, at = c(1,3,5,7,9), lty=0)

Duncan Murdoch

-----Original Message-----
From: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk] 
Sent: Wednesday, October 01, 2008 10:38 AM
To: Schreiber, Stefan
Cc: r-help at r-project.org
Subject: Re: [R] shifting ticks to left or right

Schreiber, Stefan wrote:
> Hey list,
>
> Does anybody knows a command to centre the tick mark labels exactly
> between the tick points (right shift)?
> And then to exclude the last tick label on  the right?
>
> I know one can shift them using the 'hadj' option in par. But I am
> wondering if there is a more convenient command!
>
> Thanks a lot!!
>
> Stefan
>   
Hmm, are you solving the right problem there? Sounds like it would be 
easier to do TWO axes,  one with no labels and another with no tickmarks:

z<-seq(from=.5,length=10)
plot(z,sin(z),xaxt="n", xlim=c(0,10))
axis(1,at=z, labels=letters[1:10], tick=F)
axis(1,at=0:10, labels=F)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list