Some notes on adjusting margins and using the mtext() function to place axis labels closer the axes.
data(iris)
with(iris, plot(Sepal.Length ~ Petal.Length))
Here, I decrease the top and left margins to 1.
par(mar = c(5,4,1,1))
with(iris, plot(Sepal.Length ~ Petal.Length))
Here, I decrease the top and left margins to 1.
with(iris, plot(Sepal.Length ~ Petal.Length,
xlab = "Petal Length",
ylab = "Sepal length"))
with(iris, plot(Sepal.Length ~ Petal.Length,
xlab = "",
ylab = ""))
with(iris, plot(Sepal.Length ~ Petal.Length,
xlab = "",
ylab = ""))
#add text
mtext(text = "Petal Length",
side = 1,#side 1 = bottom
line = 2)
with(iris, plot(Sepal.Length ~ Petal.Length,
xlab = "",
ylab = ""))
# x axis
mtext(text = "Petal Length",
side = 1,line = 2)
# y axis
mtext(text = "Sepal Length",
side = 2, #side 2 = left
line = 2)
par(mar = c(3,3,1,1))
with(iris, plot(Sepal.Length ~ Petal.Length,
xlab = "",
ylab = ""))
# x axis
mtext(text = "Petal Length",
side = 1,line = 2)
# y axis
mtext(text = "Sepal Length",
side = 2, #side 2 = left
line = 2)
If for some reason you want no tick marks and no numbers along the axies, you can set par(yaxt = “m”)
#change par
par(yaxt="n",#remove from y
xaxt='n')#remove from x
with(iris, plot(Sepal.Length ~ Petal.Length))
Set it back tiwht yaxt = “t”
#change par
par(yaxt="t",#remove from y
xaxt='t')#remove from x
with(iris, plot(Sepal.Length ~ Petal.Length))