[R] Space for X and Y axis labels

Joseph Wakeling joseph.wakeling at webdrake.net
Fri Mar 23 20:54:41 CET 2007


Hello all,

I'm having a bit of a problem with x and y axis labels.  Two things:
first, if I want to create a plot with,

    plot.new()
    plot.window(.....)
    axis(1)
    axis(2)
    lines(...)
    points(...)

    [etc.]

... where do I introduce the xlab=... and ylab=... commands?  I
attempted this in plot.window() but no labels showed up.

Second, here's a bit of real code...

	postscript(file="RPDfig.eps",onefile=FALSE,
	 +         horizontal=FALSE,paper="special",height=8.3,
         +         width=11.7)
	matplot(2:length(PRICE),t(NWpd),type="l",xlim=c(0,200),
	 +      ylim=c(-0.1,0.1),xaxs="i",yaxs="i",xlab="Time",
	 +      ylab=expression(over(x,y)),bty="n")
	points(2:length(PRICE),Ppd,col="red")
	dev.off()

Here the y label is meant to be x over y (a fraction), but the top part
of the fraction is cut off by the border of the graphic.  How can I fix
this, either by creating extra space for the label or by insisting that
the boundary of the graphic be extended to embrace the whole of the
label?  I've tried setting xpd=TRUE in the matplot command, but I'm not
sure that is the correct option (and it makes no difference).

Many thanks,

    -- Joe



More information about the R-help mailing list