And the answer is...

mtext("the upper one?", side=3, line = par("mgp")[1])


2008/6/19 Dan Bolser <[EMAIL PROTECTED]>:

> I would like to set the 'xlab' on the 'upper' x axis. The following code
> shows roughly what I want by way of (one possible) expected behaviour.
>
> par(mar=c(5.1, 4.1, 5.1, 2.1))
> plot(rnorm(10), rnorm(10), xlab="the lower one")
> axis(3, xlab="the upper one????")
>
> There are various other ways that could be expected to work, but hopefully
> the above is clear enough to show you what I want to achieve.
>
> The following works, but is fragile (works without resizing the window of
> an X11 device).
>
> title(xlab="the upper one", line=-28)
>
>
> Is there any better way to do it other than tinkering with 'line='?
>
>
> Here is the same code as above but with comments just for reference.
>
> # Give upper and lower margins an equal size
> par(mar=c(5.1, 4.1, 5.1, 2.1))
>
> # Plot (labeling the lower x axis)
> plot(rnorm(10), rnorm(10), xlab="the lower one")
>
> # Add the upper x axis (labeling fails!)
> axis(3, xlab="the upper one????")
>
> # Works but is fragile
> title(xlab="the upper one", line=-28)
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to