[R] Setting the xlab for 'the other' (upper) X axis?

From: Dan Bolser <dan.bolser.r_at_googlemail.com>
Date: Thu, 19 Jun 2008 11:16:48 +0200

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_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. Received on Thu 19 Jun 2008 - 09:26:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 19 Jun 2008 - 12:30:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive