Bring axes numbering closer

I've been working in several R base graphics plots. I'd like to know how to set the axes numbering closer to them, since the default placing is located too far for what I want.

Thank you in advance for your help!

This shows all the parameters you can change:

To see the default settings try e.g.

Is it possible to do it with base graphics instead of ggplot?

In general, par is how you set graphical parameters for base graphics. Some graphical parameters can be set as arguments to plot. You can adjust axis spacing with mgp. Here are some simple examples:

# default values of mgp 
plot(1:10, 1:10, mgp = c(3, 1, 0))
# move axis titles closer
plot(1:10, 1:10, mgp = c(2, 1, 0))
# move axis labels closer
plot(1:10, 1:10, mgp = c(2, 0.5, 0))
# move axis lines away from plot
plot(1:10, 1:10, mgp = c(3, 1, 0.5))

Thank you very much for your help! That's exactly what I was looking for!

1 Like