[R] plot + axis: Individually moving tick labels with hadj?

Sarah Goslee sarah.goslee at gmail.com
Fri Jun 3 13:14:42 CEST 2011


Hi Marius,

I actually prefer the first (default) arrangement, with the labels centered, but
if you want to align the equals under the tick mark one option is to use
axis() twice:

plot(1:5, 5:1, xaxt="n")
axis(1, at=1:5, labels=c(1,2,"",4,5))
axis(1, at=3.15, tick=FALSE, labels=expression(3==beta[foooooo]))

Sarah

On Fri, Jun 3, 2011 at 7:02 AM, Marius Hofert <m_hofert at web.de> wrote:
> Dear all,
>
> consider the following plot:
>
> plot(1:5, 5:1, xaxt="n")
> axis(1, at=1:5, labels=c(1,2,expression(3==beta[foooooo]),4,5))
>
> the label at 3 is not nice, so consider this
> plot(1:5, 5:1, xaxt="n")
> axis(1, at=1:5, labels=c(1,2,expression(3==beta[foooooo]),4,5),
>     padj=c(0,0,0.18,0,0))
>
> Now I tried to move the label horizontally so that the equality sign is
> vertically aligned with the tick. Since hadj moves all labels, I tried:
> plot(1:5, 5:1, xaxt="n")
> axis(1, at=1:5, labels=c(1,2,expression(3==beta[foooooo]),4,5),
>     hadj=c(0,0,0.22,0,0), padj=c(0,0,0.18,0,0))
>
> Why is it not possible to individually move the labels horizontally?
> Simply moving all of them does not look very good...
> plot(1:5, 5:1, xaxt="n")
> axis(1, at=1:5, labels=c(1,2,expression(3==beta[foooooo]),4,5),
>     hadj=0.22, padj=c(0,0,0.18,0,0))
>
> Cheers,
>
> Marius
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list