[R] controlling location of labels in axis()

Toby Marthews Toby.Marthews at lsce.ipsl.fr
Thu Jun 12 15:53:43 CEST 2008


Hi Andrew,

Perhaps this example would help. You can add in spaces to the mtext text
to move the text sideways.

par(mai=c(0.5,0.5,0.5,0.5),oma=c(2,2,2,2))	#mai units are INCHES, oma
units are LINES
plot(runif(50),xlab="xlab",ylab="ylab",bty="l")	#n.b. these labels don't
appear
mtext("First inner x axis label",side=1)
mtext("First inner y axis label",side=2)
mtext("Second inner x axis label",side=3)
mtext("Second inner y axis label",side=4)
mtext("First outer x axis label",side=1,outer=TRUE)
mtext("First outer y axis label",side=2,outer=TRUE)
mtext("Second outer x axis label",side=3,outer=TRUE)
mtext("Second outer y axis label",side=4,outer=TRUE)

Cheers,
Toby Marthews

Le Jeu 12 juin 2008 15:32, Andrew Yee a écrit :
> Here's a naive question about axis()
>
> How do you control the location of the labels with the axis() command?
>
> In the following example:
>
> foo <- data.frame(plot.x=seq(1:3), plot.y=seq(4:6))
> plot(foo$plot.x, foo$plot.y, type='n', axes=FALSE)
> points(foo$plot.x, foo$plot.y)
> axis(1, at=foo$plot.x, labels=foo$plot.x)
>
> I'd like to be able the control the y location of the labels (i.e. move
up
> or down in the graph).
>
> Thanks,
> Andrew



More information about the R-help mailing list