Bring axes numbering closer


#1

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!


#2

This shows all the parameters you can change:
https://ggplot2.tidyverse.org/reference/theme.html

To see the default settings try e.g.
ggplot2::theme_grey()


#3

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


#4

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))

#5

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