[R] controlling plot spacing?

Paul Murrell paul at stat.auckland.ac.nz
Thu Apr 19 22:44:08 CEST 2001


Hi

I think you want par(mgp).  For example, try ...

par(mfrow=c(2,2), mar=rep(6,4), mgp=c(3, 1, 0))
plot(1:10, xlab="default position", ylab="default position")
box("figure", lty="dashed")
par(mgp=c(4, 1, 0))
plot(1:10, xlab="axis label further out", ylab="axis label further out")
box("figure", lty="dashed")
par(mgp=c(4, 2, 0))
plot(1:10, xlab="tick labels further out too", ylab="tick labels further out
too")
box("figure", lty="dashed")
par(mgp=c(1.5, .6, 0))
plot(1:10, xlab="both labels closer in", ylab="both labels closer in")
box("figure", lty="dashed")

For finer control, you will probably need to use mtext() to draw the labels
yourself.

Hope that helps.

Paul


>   Suppose I have the bottom axis of a plot that looks like:
>
> ----+----+----+----+----+----+----
>     |    |    |    |    |    |
>
>
>     1    2    3    4    5    6
>
>
>           Axis title
>
> 1. How do I reduce the gap between the ends of the ticks and the axis
> labels (numbers)?
>
> 2. How do I vary the gap between the bottom of the axis labels and the top
> of the axis title?
>
> I have looked in various places (help for par, axis, plot) but haven't
> found the solutions.  Thanks for any help.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list