Home > Enterprise >  Changing the position of axis lables closet to the plot in r
Changing the position of axis lables closet to the plot in r

Time:08-07

I am using the plot() function in r using these codes:

plot(x= T38$Variables,
     y= T38$Q5_E_38, type = "b", pch=16, col = "red", 
     xlab = "", ylab = "", yaxt = "n", 
     xaxt= "n", main="RMSE ")
title(xlab = "Variables", line =1.5, cex.lab = 1.5)
title(ylab = "RMSE"     , line =1.5, cex.lab = 1.5 )
axis(2, at= T38$Q5_E_38[37], col="red", cex.axis=0.6)
axis(1, cex.axis=0.6)

My problem is that the axis labels are too distant from the axis. I need to bring them closer to the axis. Please see the following picture. How Can I bring the numbers closer to the axis in Plot()? in this picture you can see that the label covers the numbers

CodePudding user response:

Taking your x-axis for example:

axis(side = 1, labels = FALSE)
mtext(axTicks(1), side = 1, line = 0.5, at = axTicks(1), cex = 0.6)

Adjust line = ? as you see fit.

  • Related