6

I would like to move the axes labels closer to my plot. How can I do that?

set.seed(3)
plot(rnorm(10), xlab = "Age", ylab = "Weight", cex.lab = 1.5)

enter image description here

Adrian
  • 9,229
  • 24
  • 74
  • 132
  • Does the last part of the answer [here](http://stackoverflow.com/questions/12302366/moving-axes-labels-in-r) help? – alexforrence Jun 11 '15 at 23:34
  • Thank you very much! By the way, is there a way to change the line thickness in the plot function? – Adrian Jun 11 '15 at 23:50

2 Answers2

7

I think the command you're looking for is:

par(mgp=c(2,1,0))  

Then create your plot:

plot(rnorm(10), xlab = "Age", ylab = "Weight", cex.lab = 1.5)

Once you're done you can reset it to the default:

par(mgp=c(3,1,0))
Adam C
  • 334
  • 1
  • 9
3

Using title() and specifying line should work for you. You may also want to consider changing the margins via par(oma = c()) or par(mar = c()) (the sequence of numbers goes: bottom, left, top, right).

set.seed(3)
plot(rnorm(10), xlab = "Age", ylab = "", cex.lab = 1.5)
title(ylab = "Weight", line = 2, cex.lab = 1.5)

Hope it helps

Daniel Anderson
  • 2,394
  • 13
  • 26