[R] defining the distance between axis label and axis

Marc Schwartz marc_schwartz at comcast.net
Wed Aug 6 22:41:28 CEST 2008


on 08/06/2008 03:21 PM Jörg Groß wrote:
> Hi,
> 
> How can I make the distance between an axis-label and the axis bigger?
> 
> I haven't found anything in par()...

Depends upon what you mean by the axis labels...

If by axis labels, you are referring to the text annotation typically 
centered on the axis (eg. below the x axis or to the left of the y 
axis), you will likely want to set 'ann = FALSE' in the plot call and 
then use mtext() to place the text.

Example:

   plot(1:10, ann = FALSE)

   mtext(side = 1, text = "X Axis", line = 3)

   mtext(side = 2, text = "Y Axis", line = 3)


See ?plot.default and ?mtext for more information.


If on the other hand, you are talking about the placement of the text 
placed at each tick mark on the axis, look again at ?par and take note 
of 'mgp', specifically, the middle value of the vector.

For example, compare:

   plot(1:10, mgp = c(3, 1, 0))

with:

   plot(1:10, mgp = c(3, 2, 0))


HTH,

Marc Schwartz



More information about the R-help mailing list